- Create origin branch when creating branch
git config --global branch.autosetupmerge always
- Add ssh key to keychain to eliminate retyping in password
ssh-add -K ~/.ssh/id_rsa
- Add All Files -
git add .
- Add new changes -
git commit --amend
- Change commit author -
git commit --amend --author="John Doe <[email protected]>"
- Create and checkout branch -
git checkout -b {branch_name}
- Create branch -
git branch {branch_name}
- Delete branch -
git branch -D {branch_name}
- List branches -
git branch --list
- Fetch latest -
git fetch
- file commit log -
git log {current path to file}
-git log src/compenents/some.js
- Push:
git push
- Push Origin:
git push -u origin {branch-name}
- Force Push:
git push -f
- Interactive Rebase on to same branch:
git rebase -i
- Rebase on to different branch:
git rebase -i {branch}
- Rebase the top X commits:
git rebase -i {branch} HEAD~X
- Reset commit (keep changes):
git reset --soft HEAD~{number of commits}
- Reset commit (delete changes):
git reset --hard HEAD~{number of commits}