work:git-guide
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
work:git-guide [2013/04/27 21:41] – [删除服务器branch] percy | work:git-guide [2016/11/04 16:55] – percy | ||
---|---|---|---|
Line 363: | Line 363: | ||
==== git checkout remote branch ==== | ==== git checkout remote branch ==== | ||
Check the remote branch list | Check the remote branch list | ||
- | git branch -r | + | git branch -rv |
Then create a local branch from the remote branch | Then create a local branch from the remote branch | ||
git checkout -b test origin/test | git checkout -b test origin/test | ||
| | ||
+ | Commit to a remote branch: | ||
+ | git push origin proguard | ||
+ | | ||
+ | Reference: | ||
+ | | ||
+ | ==== git add local to the remote | ||
+ | < | ||
+ | git init | ||
+ | git remote add origin https:// | ||
+ | git status | ||
+ | git pull | ||
+ | git pull origin master | ||
+ | git status | ||
+ | git add . | ||
+ | git commit -m "init commit" | ||
+ | git push origin master | ||
+ | </ | ||
+ | ==== change url ==== | ||
+ | git remote set-url origin https:// | ||
+ | |||
+ | ==== create patch ==== | ||
+ | |||
+ | git show 3514997d38509ab5492e32afc3e4e872daf7932e > | ||
+ | patch -p1 < | ||
+ | | ||
+ | Or you can create patch between two commitid | ||
+ | git diff old-commitid new-commitid > | ||
+ | git diff 557393295b0811278de4875d5fc5558988371bca 0abea5c74c10b81672817aa93ae21cc4852b7702 > | ||
+ | | ||
+ | If you want to revert your patch -R | ||
+ | patch -R -p1 < | ||
+ | | ||
+ | |||
+ | ==== git auto-complete ==== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | wget https:// | ||
+ | sudo vim /etc/bashrc | ||
+ | source / | ||
+ | | ||
+ | ==== git alias ==== | ||
+ | | ||
+ | http:// | ||
+ | | ||
+ | <code BASH> | ||
+ | git config --global alias.co checkout | ||
+ | git config --global alias.br branch | ||
+ | git config --global alias.ci commit | ||
+ | git config --global alias.st status | ||
+ | git config --global alias.visual ' | ||
+ | </ | ||
+ | |||
+ | ==== git tag ==== | ||
+ | |||
+ | < | ||
+ | git tag release/ | ||
+ | git tag -l | ||
+ | git push origin tag release/ | ||
+ | </ | ||
+ | |||
+ | ==== git checkout tag ==== | ||
+ | First make sure that the tag exists locally by doing | ||
+ | |||
+ | git fetch --tags | ||
+ | Then check out the tag by running | ||
+ | git checkout tags/< | ||
+ | | ||
+ | Then create new branch base on the current commitment | ||
+ | git branch newtagbranch | ||
+ | | ||
+ | ==== git fetch & git merge ==== | ||
+ | |||
+ | Refer to | ||
+ | - http:// | ||
+ | - http:// | ||
+ | - http:// | ||
+ | |||
+ | < | ||
+ | git checkout feature/ | ||
+ | git fetch origin feature/ | ||
+ | git diff tmp | ||
+ | git merge tmp | ||
+ | |||
+ | git checkout feature/ | ||
+ | git fetch --all | ||
+ | git fetch origin feature/ | ||
+ | git diff feature/ | ||
+ | git merge origin/ | ||
+ | |||
+ | git branch -D tmp | ||
+ | |||
+ | git checkout feature/ | ||
+ | git fetch origin feature/ | ||
+ | git checkout -b newBrach origin/ | ||
+ | |||
+ | #Delete the local branch that already deleted from the remote | ||
+ | git remote prune origin | ||
+ | |||
+ | #Remote server | ||
+ | git remote -v | ||
+ | |||
+ | #Remote branch | ||
+ | git branch -r | ||
+ | #All branch | ||
+ | git branch -a | ||
+ | |||
+ | #Show the remote repo information | ||
+ | git remote show origin | ||
+ | git remote prune origin | ||
+ | </ | ||
+ | |||
+ | ==== git subtree ==== | ||
+ | Refer to | ||
+ | http:// | ||
+ | <code bash> | ||
+ | git remote add -f datalayer | ||
+ | git subtree add --prefix=datalayer datalayer integration_lean --squash | ||
+ | git fetch all --prune | ||
+ | git fetch datalayer integration_lean | ||
+ | git subtree pull --prefix=datalayer/ | ||
+ | git subtree push --prefix=datalayer/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== git checkout specified file from another branch ==== | ||
+ | |||
+ | * http:// | ||
+ | |||
+ | git checkout branch_name -- path/ | ||
+ | | ||
/var/www/dokuwiki/wiki/data/pages/work/git-guide.txt · Last modified: 2018/02/05 19:15 by percy