Skip to content

Instantly share code, notes, and snippets.

@franee
Last active July 9, 2021 11:36
Show Gist options
  • Save franee/a4b2792f1cabb80b15212f2518322ce7 to your computer and use it in GitHub Desktop.
Save franee/a4b2792f1cabb80b15212f2518322ce7 to your computer and use it in GitHub Desktop.
everyday git commands
# starting projects
git clone <repo>
git init - turn a directory to a git repo
git remote add origin <remote-url> - link to remote repo e.g github project
# feature work
git checkout -b <branch-name> - create branch
git checkout <branch-name> - switch to branch
git branch -D <branch-name> - delete branch
git status
git add <file / folder>
git rm <file>
git commit -m "<message>" - oneliner
git commit
git fetch - fetch remote changes (does not do anything to local branches)
git rebase <branch>
git rebase -i <branch> - interactive rebase
git merge <branch>
git reset --hard origin/<branch> - make current branch be the same as remote branch
git reset HEAD~ - remove topmost commit
git add <file/folder>
git add -u - adds all files displayed in git status
# typical workflow
git checkout -b <branch-name> - create branch
do some changes
git add -u
git commit -m "<message>"
git push origin <branch-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment