DEV Community

Cover image for Basic Git Cheat Sheet
David Snyder
David Snyder

Posted on

Basic Git Cheat Sheet

Need to Know git commands

  1. git init (Initialize git repository)
  2. git checkout {branchname} - change the working branch
  3. git checkout -b {branchname} - create a branch and change the working branch into it
  4. git status - check for untrack and tracked files
  5. git add . - track changes in all files in the working branch
  6. git add {filename} - track changes in one file
  7. git commit -m “message” - save changes to local repository
  8. git remote add origin {remote url} - connecting to a remote repository
  9. git push origin {branchname} - push code from local to remote
  10. git push -u origin {branchname} - push code from local to remote on a branch that doesn't already exist on remote
  11. git merge {branchname} - merge changes from {branchname} into the current working branch

Note: Please remember not to work on master branch directly, always create different branches for different purposes.

Top comments (0)