User Tools

Site Tools


work:git-guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
work:git-guide [2013/04/27 21:41] – [删除服务器branch] percywork: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:http://stackoverflow.com/questions/1783405/git-checkout-remote-branch
 +  
 +==== git add local to the remote  ====
 +<code>
 +git init
 +git remote add origin https://github.com/pjq/SoundRecordingExample2.git
 +git status
 +git pull
 +git pull origin master
 +git status
 +git add .
 +git commit -m "init commit"
 +git push origin master
 +</code>
  
 +==== change url ====
 +  git remote set-url origin https://github.com/jikabao/merchantapp_android.git
 +
 +==== create patch ====
 +
 +  git show 3514997d38509ab5492e32afc3e4e872daf7932e >DashboardGLPLTitle.patch
 +  patch -p1  <DashboardGLPLTitle.patch
 +  
 +Or you can create patch between two commitid
 +  git diff old-commitid new-commitid >diff.patch
 +  git diff 557393295b0811278de4875d5fc5558988371bca 0abea5c74c10b81672817aa93ae21cc4852b7702 >diff.patch
 +  
 +If you want to revert your patch -R
 +  patch -R -p1 <../diff.patch
 +  
 + 
 +==== git auto-complete ====
 +
 +http://blog.jameschevalier.us/how-to-add-auto-completion-to-git/
 +
 +  wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion
 +  sudo vim /etc/bashrc
 +  source /Users/pengjianqing/.git-completion
 +  
 +==== git alias ====
 +  
 +http://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks
 +  
 +<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 '!gitk'
 +</code>
 +
 +==== git tag ====
 +
 +<code>
 +   git tag release/1.2.9
 +   git tag -l
 +   git push origin tag release/1.2.9
 +  </code>
 +
 +==== 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/<tag_name>
 +  
 +Then create new branch base on the current commitment
 +  git branch newtagbranch
 +  
 +==== git fetch & git merge ====
 +
 +Refer to
 +  - http://www.ruanyifeng.com/blog/2014/06/git_remote.html
 +  - http://www.cnblogs.com/youxin/p/3470335.html
 +  - http://longair.net/blog/2009/04/16/git-fetch-and-merge/
 +
 +<code>
 +git checkout feature/sp_xd
 +git fetch origin feature/sp_xd:tmp
 +git diff tmp
 +git merge tmp
 +
 +git checkout feature/sp_xd
 +git fetch --all
 +git fetch origin feature/sp_xd
 +git diff feature/sp_xd origin/feature/sp_xd
 +git merge origin/feature/sp_xd
 +
 +git branch -D tmp
 +
 +git checkout feature/sp_xd
 +git fetch origin feature/sp_xd
 +git checkout -b newBrach origin/feature/sp_xd
 +
 +#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
 +</code>
 +
 +==== git subtree ====
 +Refer to
 +http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/
 +<code bash>
 +git remote add -f datalayer   https://Jianqing.Peng@stash.englishtown.com/scm/mobile/datalayer-android.git 
 +git subtree add  --prefix=datalayer datalayer integration_lean --squash
 +git fetch all  --prune   
 +git fetch datalayer integration_lean
 +git subtree pull --prefix=datalayer/ datalayer integration_lean --squash
 +git subtree push --prefix=datalayer/ datalayer integration_lean
 +</code>
 +
 +
 +==== git checkout specified file from another branch ====
 +
 +  * http://stackoverflow.com/questions/2364147/how-to-get-just-one-file-from-another-branch
 +
 +  git checkout branch_name -- path/to/file
 +  
  
/var/www/dokuwiki/wiki/data/pages/work/git-guide.txt · Last modified: 2018/02/05 19:15 by percy