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
work:git-guide [2014/12/04 02:51] – [create patch] percywork:git-guide [2018/02/05 19:15] (current) – [git checkout specified file from another branch] percy
Line 384: Line 384:
 git push origin master git push origin master
 </code> </code>
 +
 +==== change url ====
 +  git remote set-url origin https://github.com/jikabao/merchantapp_android.git
  
 ==== create patch ==== ==== create patch ====
Line 405: Line 408:
   sudo vim /etc/bashrc   sudo vim /etc/bashrc
   source /Users/pengjianqing/.git-completion   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
 +  
 +==== git revert ====
 +
 +github support revert the pull request, so after you have revert the pull request, and still want to merge the feature branch, then you need to find the revert commit id, and revert it again
 +
 +  git revert ce8731f5cbc55ab50723ee2a8ec615b462b3b0e6 -m 1
 +
 +So the full log will be like
 +<code>
 +commit 817947e37c5f835384fd282ab2004a6d9a848975 (HEAD -> pjq/testing, origin/pjq/testing)
 +Author: Jianqing Peng <Jianqing.Peng@sap.com>
 +Date:   Mon Feb 5 19:09:40 2018 +0800
 +
 +    Revert "Merge pull request #2087 from sfofficial/revert-2086-pjq/testing_new_feature"
 +    
 +    This reverts commit ce8731f5cbc55ab50723ee2a8ec615b462b3b0e6, reversing
 +    changes made to 67a513f686ec9c203b7d38a3df1abbe7079320d4.
 +
 +commit ce8731f5cbc55ab50723ee2a8ec615b462b3b0e6
 +Merge: 67a513f686 a157cdef4e
 +Author: Jianqing Peng <jianqing.peng@sap.com>
 +Date:   Mon Feb 5 19:07:33 2018 +0800
 +
 +    Merge pull request #2087 from sfofficial/revert-2086-pjq/testing_new_feature
 +    
 +    Revert "add new feature 1"
 +
 +commit a157cdef4e391981b2053b52f560a70464b2dd7f
 +Author: Jianqing Peng <jianqing.peng@sap.com>
 +Date:   Mon Feb 5 19:06:29 2018 +0800
 +
 +    Revert "add new feature 1"
 +
 +commit 67a513f686ec9c203b7d38a3df1abbe7079320d4
 +Merge: 08a5c9c33e a161eed1e3
 +Author: Jianqing Peng <jianqing.peng@sap.com>
 +Date:   Mon Feb 5 19:05:57 2018 +0800
 +
 +    Merge pull request #2086 from sfofficial/pjq/testing_new_feature
 +    
 +    add new feature 1
 +
 +commit a161eed1e3d200f6121690494dd6df1d065163fb (origin/pjq/testing_new_feature, pjq/testing_new_feature)
 +Author: Jianqing Peng <Jianqing.Peng@sap.com>
 +Date:   Mon Feb 5 19:05:11 2018 +0800
 +
 +    add new feature 1
 +
 +
 +</code>
/var/www/dokuwiki/wiki/data/attic/work/git-guide.1417632691.txt.gz · Last modified: 2016/05/05 13:06 (external edit)