Lokvin Wiki
Advertisement

doc

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


  • 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
git push -u origin master
  • Existing Git Repo ?
cd existing_git_repo
git remote add origin git@gitlab.media.int.thomsonreuters.com:yufei-cn/test-prj.git
git push -u origin master

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

git revert change

git reset --hard

git submodule

GitHub

github synchronize 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

  • 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]
Advertisement