Common
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
git status git add <file> git add . git commit -m 'commit content' //Clone a repo into current folder git clone git@bitbucket.org:partners/tw.git . git push git pull //Discard unstaged changes git checkout -- <file> git checkout -- . //Check difference between files git diff hello.txt //Merge from branch dev or remote branch origin/testing git merge dev git merge origin/testing //Check difference between last 2 git log -p -2 //Checkout a remote branch git checkout --track origin/dev //Push to remote branch git push -u origin dev //Set track of a local branch git branch -u origin/dev //Stop tracking a file git rm --cached worker.log git rm -r --cached path_to_your_folder/ // Show all remote URL git remote -v // Show files in a commit //https://stackoverflow.com/questions/424071/how-to-list-all-the-files-in-a-commit git show --pretty="" --name-only bd61ad98 |
push.default warning
1 |
git config --global push.default simple |
Ignored files still display in git status?
1 |
git rm --cached <file> |
- Warning! If other users pull this commit, this file will be removed, so remember notify others to backup their files if they need it. e.g. index.php for Codeigniter
- https://stackoverflow.com/questions/1818895/keep-ignored-files-out-of-git-status
Set User Info
1 2 |
git config --global user.name "xxx"<code> |
Reference:
- Official Doc
https://git-scm.com/book/zh-tw/v1/Git-%E5%9F%BA%E7%A4%8E-%E5%8F%96%E5%BE%97Git%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E5%80%89%E5%BA%AB - https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch
- https://git-scm.com/book/zh-tw/v1/Git-%E5%9F%BA%E7%A4%8E-%E6%AA%A2%E8%A6%96%E6%8F%90%E4%BA%A4%E7%9A%84%E6%AD%B7%E5%8F%B2%E8%A8%98%E9%8C%84
Change Remote URL
1 |
git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git |
Reference: https://gist.github.com/fokayx/255b228ded2bca1c4f60