You say 'developer,' I hear the Git clan. Diverse languages, one mission: Git. It tracks every change, keeps your code safe, and makes collaboration effortless. In short, git is a version control system that helps track changes in code and collaborate efficiently across teams.
A typical Git workflow can be summarized as:
Git Repo (created or cloned) → changes → add → commit → pull → push
Configuration
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --list
Clone a repository
git clone <repository_link>
Check status
git status
Possible responses:
untracked – new files not added
modified – changed but not staged
staged – added and ready to commit
unmodified – no changes
Add changes
git add . (stages all changes)
Commit changes
git commit -m "Your message"
Push changes
git push origin main
git push -u origin main
git push origin branch_name
Initialize repository
git init
Manage remotes
git remote add origin <repository_link>
git remote -v
Branch management
git branch -M branch_name (rename branch)
git branch -d branch_name (delete branch)
Switch or create branches
git checkout -b branch_name (create and switch)
git checkout branch_name (switch)
View differences
git diff branch_name
Merge branches
git merge branch_name
You can undo changes using git reset. The fork command allows you to create a personal copy of a repository to experiment without affecting the original.
Q1. How do we push changes to a branch?
git push origin branch_name
Q2. After merging locally, do we still need a pull request (PR)?
If you’ve merged locally, you only need to push the merged branch to the remote. A PR is required when merging on the remote repository, so the local merge doesn’t always require a PR unless you want team review.