gitlab create new project

  • git global setup
git config --global "Yufei Ren"
git config --global ""

check git config

git config --list


>ssh-keygen -t rsa -C "email@address"

git change origin url

git remote set-url origin new_git_url

For ssh protocol (eg:

Add below two lines to your ~/.ssh/config

   ProxyCommand ssh distuser@ "nc %h %p"

For http,https protocol (eg:

Run below command to add corresponding configs to ~/.gitconfig.

$ git config --global http.proxy

For git protocol (eg: git://

Create /usr/local/bin/gitproxy.cmd with below content:

ssh distuser@ "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

git revert change

git reset --hard
  • revert code to previous commit
git checkout rev_no .

git submodule


github synchronize a fork


>git clone
>cd DiscoverMeteor_zh
lokvins-MBP:DiscoverMeteor_zh lokvin$ git remote -v
origin (fetch)
origin (push)
>git remote add upstream
>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 


git branch new_branch_name
git checkout new_branch_name
  • git branch -r

list remote branch

 $ git branch -r
 origin/HEAD -> origin/master
  • 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
Community content is available under CC-BY-SA unless otherwise noted.