CanadaTechLife

Git Workflow - Common Commands 2026

Apr 15th, 2026
56
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.31 KB | None | 0 0
  1. Git is the backbone of modern version control. Whether you’re a solo dev or part of a massive team, these 20 commands cover about 95% of your daily interactions with a repository.
  2. Getting Started & Setup
  3. git init: Initializes a brand-new local Git repository in your current folder.
  4. git clone [url]: Downloads an existing repository from a remote source (like GitHub) to your machine.
  5. git config --global user.name "Name": Sets the name that will be attached to your commit transactions.
  6.  
  7. The Staging Area & Basics
  8. git status: The "Where am I?" command. It shows which files are modified, staged, or untracked.
  9. git add [file]: Moves changes from the working directory to the Staging Area. Use git add . to stage everything.
  10. git commit -m "message": Records the staged snapshot permanently in the version history.
  11. git diff: Shows the exact line-by-line changes in files that are not yet staged.
  12.  
  13. Branching & Switching
  14. git branch: Lists all local branches. Adding a name (e.g., git branch feature-x) creates a new branch.
  15. git checkout [branch]: Switches your working directory to the specified branch.
  16. git checkout -b [new-branch]: A shortcut that creates a new branch and switches to it immediately.
  17. git switch [branch]: A more modern, intuitive command specifically for changing branches.
  18.  
  19. Merging & Syncing
  20. git merge [branch]: Integrates the history of the specified branch into your current active branch.
  21. git pull: Fetches updates from the remote server and immediately merges them into your local branch.
  22. git fetch: Downloads all history from the remote tracking branches but does not merge them into your local work.
  23. git push: Uploads your local branch commits to the remote repository.
  24.  
  25. Inspection & Cleanup
  26. git log: Displays the commit history for the current branch.
  27. git show [commit]: Shows the metadata and content changes of a specific commit.
  28. git stash: Temporarily shelves uncommitted changes so you can work on something else without committing "work in progress."
  29. git stash pop: Brings your stashed changes back into your working directory.
  30. git remote -v: Lists the remote repositories (URLs) linked to your local project.
  31.  
  32. Pro Tip: If you ever get stuck in a "Vim" screen after a merge or commit, type :q! and hit Enter to exit without saving, or :wq to save and exit. It's a rite of passage for every developer!
Advertisement
Comments
Add Comment
Please, Sign In to add comment