git remote set-url origin git://new.url.here
- unstage file
git reset HEAD <file>
git checkout -- <file>
- check log
git log --oneline
- check log and show graph
git log --online --decorate --graph --all
- append a file to commit
git add <file>
git commit --amend --noe-dit # add file to latest commit without changing comment
git commit --amend # add file to latest commit AND change commit's comment
- Rebase
git checkout <feature-branch>
git rebase master # append feature-branch with commit from master
- fetch
git pull = git fetch + git merge
- pull with rebase
# use when doing with small feature, hot fix
git pull --rebase <remote> <branch>
- reflog
use git reflog
to check and restore commit that has been reseted and can not recover by ordinary commit in git log
- tag
- lightweight: use on general case
git tag 1.0.0-beta
- annotated: is a git object (commit), containing lots of info as ordinary commit
git tag -a 1.0.0 -m "mature release"
- search
git tag -l "1.0*"
- update ( switch commit)
git tag -a <tag-name> -f <commit>
- delete
git tag <tag-name> --delete
- push to remote
git push <remote> --tags
- delete remote tag
git push <remote> :<tag-name>
- push only annotated tags
Hint: should push only annotated tags to github for clarification
git push <remote> --follow-tags
- push annotated by default
git config --global push.followTags true
- checkout tag
git branch -b <new-branch-name> <tag>
- stash
git stash save "<message>" # save stash with name
git stash -u # stash both tracked and untracked file
git stash list # list all stashes
git stash --keep-index # don't stash staged file
git stash apply stash@{0} # apply single stash
git stash apply --index # apply and retain staged file
git stash drop stash@{0} # drop single stash
git stash pop stash@{0} # apply & drop at the same time
git stash clear # clear all
git stash branch <branch-name> # migrate stash files to new branch
Clone with folder name:
Add ticket number as prefix