Useful commands with Git
A list of Git commands that are practically useful even after years of experience
Repository Aladdin
- Create new respository by GitHub webinterface
- git init
- git remote add origin git@github.com:Thanh-Truong/Aladdin.git
- git push -u origin master
Work routine:
- only read Participating that someone mentions you.
- when you have more time or get bored Notifications
- if you even have time, check new issues that are interesting to follow
Shortcuts
Searching issues and pull requests
https://help.github.com/articles/searching-issues-and-pull-requests/
More tips
- Refine Github experience
- If you want to know what your colleagues are doing on Github ? Check Devspace
Commands
- Reset changes
git reset --hard
- New branch locally
git branch xx
git checkout typexx
- Fetch new branch from remote
git fetch origin xx
git checkout xx
- List branch locally
git branch --list
- List branch remote
git branch -r
- List branch both local and remote
git branch -a
- Delete xx on local
git branch xx -D
- Delete xx on remote. Here origin is my remote
git push origin :xx
- Pull xx from remote
git pull origin xx
- Merge xx from remote
git merge origin xx
git merge origin xx --no-ff
- Squash all commit from a feature branch, which diverges from this branch
git merge origin xx --squash
- Rename old branch
#Rename branch locally
git branch -m old_branch new_branch
#Delete the old branch
git push origin :old_branch
#Push the new branch, set local branch to track the new remote
git push --set-upstream origin new_branch
- showing parents of a merge commit
git show --pretty=raw <commit hash>