Tag: sourceedit |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
== git change origin url == |
== git change origin url == |
||
git remote set-url origin new_git_url |
git remote set-url origin new_git_url |
||
− | |||
− | |||
− | |||
− | * create repository |
||
− | mkdir test-prj |
||
− | cd test-prj |
||
− | git init |
||
− | touch README |
||
− | git add README |
||
− | git commit -m 'first commit' |
||
− | git remote add origin git@gitlab.media.int.thomsonreuters.com:yufei-cn/test-prj.git |
||
⚫ | |||
− | |||
− | * Existing Git Repo ? |
||
− | cd existing_git_repo |
||
− | git remote add origin git@gitlab.media.int.thomsonreuters.com:yufei-cn/test-prj.git |
||
⚫ | |||
==For ssh protocol (eg: git@github.com:ReutersMedia/logprocnode.git)== |
==For ssh protocol (eg: git@github.com:ReutersMedia/logprocnode.git)== |
||
Line 62: | Line 45: | ||
* https://www.atlassian.com/git/tutorials/undoing-changes |
* https://www.atlassian.com/git/tutorials/undoing-changes |
||
git reset --hard |
git reset --hard |
||
+ | |||
+ | * revert code to previous commit |
||
+ | git checkout rev_no . |
||
==git submodule == |
==git submodule == |
||
Line 87: | Line 73: | ||
==git branch == |
==git branch == |
||
+ | |||
+ | * set upstream branch |
||
⚫ | |||
+ | |||
+ | * update remote branch |
||
+ | git remote update --prune |
||
+ | |||
* create a new branch |
* create a new branch |
||
git branch new_branch_name |
git branch new_branch_name |
||
Line 92: | Line 85: | ||
* git checkout -b branch |
* git checkout -b branch |
||
git checkout -b new_branch_name |
git checkout -b new_branch_name |
||
+ | # create branch ckb-1 base on origin/ckb-1 |
||
+ | git checkout -b ckb-1 origin/ckb-1 |
||
equals |
equals |
||
Line 109: | Line 104: | ||
origin/sampleBETAUSconfig |
origin/sampleBETAUSconfig |
||
− | * git branch -l |
+ | * git branch -l [--list] |
list local branch |
list local branch |
||
+ | |||
+ | * delete remote branch |
||
+ | ## after git v.1.7 |
||
+ | git push origin --delete <branchName> |
||
+ | ## before v1.7 |
||
⚫ | |||
+ | |||
+ | * git branch -l |
||
+ | * master |
||
+ | |||
+ | == untrack file == |
||
+ | * add file to .gitignore |
||
+ | * git rm --cached |
||
+ | git rm --cached .project |
||
+ | |||
+ | * or use |
||
+ | git update-index --assume-unchanged [path] |
||
+ | git update-index --no-assume-unchanged [path] |
||
+ | |||
+ | == git log graph == |
||
+ | git log --graph --all --oneline |
||
+ | |||
+ | == git rebase == |
||
+ | git rebase -i master |
||
+ | ## clean local commit |
||
+ | git rebase -i ^head |
||
+ | ## Do not do rebase on public branch |
||
+ | |||
+ | * https://www.atlassian.com/git/tutorials/merging-vs-rebasing |
Latest revision as of 03:28, 4 December 2017
doc[]
- http://gitref.org/ - git simple doc
- https://www.atlassian.com/git/tutorials/setting-up-a-repository - git tutorial from stlassian
gitlab create new project[]
- git global setup
git config --global user.name "Yufei Ren" git config --global user.email "yufei.ren@thomsonreuters.com"
check git config[]
git config --list
ssh-keygen[]
>ssh-keygen -t rsa -C "email@address"
git change origin url[]
git remote set-url origin new_git_url
For ssh protocol (eg: git@github.com:ReutersMedia/logprocnode.git)[]
Add below two lines to your ~/.ssh/config
HOST github.com ProxyCommand ssh distuser@10.90.39.170 "nc %h %p"
For http,https protocol (eg: https://github.com/mochi/mochiweb.git)[]
Run below command to add corresponding configs to ~/.gitconfig.
$ git config --global http.proxy http://10.90.7.56:3128/
For git protocol (eg: git://github.com/mochi/mochiweb.git)[]
Create /usr/local/bin/gitproxy.cmd with below content:
#!/bin/sh ssh distuser@10.90.39.170 "nc $1 $2"
And make it executable:
$ sudo chmod a+x /usr/local/bin/gitproxy.cmd
Then run below command to add corresponding configs to ~/.gitconfig.
$ git config --global core.gitproxy /usr/local/bin/gitproxy.cmd
find in which tag[]
>git describe --tags >git describe --all
git tutorials[]
- https://www.atlassian.com/git/tutorials - git tutorials from atlassian
git revert change[]
git reset --hard
- revert code to previous commit
git checkout rev_no .
git submodule[]
GitHub[]
github synchronize a fork[]
- https://help.github.com/articles/fork-a-repo/ - fork a repo
- https://help.github.com/articles/syncing-a-fork/ - syncing a fork
eg:
>git clone git@github.com:yren/DiscoverMeteor_zh.git >cd DiscoverMeteor_zh lokvins-MBP:DiscoverMeteor_zh lokvin$ git remote -v origin git@github.com:yren/DiscoverMeteor_zh.git (fetch) origin git@github.com:yren/DiscoverMeteor_zh.git (push) >git remote add upstream git@github.com:DiscoverMeteor/DiscoverMeteor_zh.git >git fetch upstream >git checkout master >git merge >git merge upstream/master
github pages[]
git branch[]
- set upstream branch
git branch -u origin/master master
- update remote branch
git remote update --prune
- create a new branch
git branch new_branch_name
- git checkout -b branch
git checkout -b new_branch_name # create branch ckb-1 base on origin/ckb-1 git checkout -b ckb-1 origin/ckb-1
equals
git branch new_branch_name git checkout new_branch_name
- git branch -r
list remote branch
$ git branch -r origin/CKB-11783 origin/CKB-11837 origin/HEAD -> origin/master origin/betausS3 origin/dbchanges origin/master origin/sampleBETAUSconfig
- git branch -l [--list]
list local branch
- delete remote branch
## after git v.1.7 git push origin --delete <branchName> ## before v1.7 git push origin :<branchName>
- git branch -l
* master
untrack file[]
- add file to .gitignore
- git rm --cached
git rm --cached .project
- or use
git update-index --assume-unchanged [path] git update-index --no-assume-unchanged [path]
git log graph[]
git log --graph --all --oneline
git rebase[]
git rebase -i master ## clean local commit git rebase -i ^head ## Do not do rebase on public branch