> git config --global --list #listing config
> git config --global user.name "melborne"
> git config --global user.email "p@gmail.com"
> git config --global color.ui "auto"
状態を見る
> git status
> git diff # see only not staged changes
> git diff --cached # see only staged changes
> git diff HEAD # see all changes
> git log -1 #check last log
> git add myfile.rb # change staging area
> git add -i # interactive mode
> git commit -m 'initial commit' # apply stage data to repo
> git mv a.txt b.txt #only required is commit
gitignore or git/info/exludeファイルに追跡しないファイルを追加(*.dbとか)
> git commit -C HEAD -a --amend #amend most recent commit with same comment
> git revert#revert a commit
> git revert -n HEAD # only revert head without commit
> git checkout#discard changes in working dir
ブランチ
> git branch RB_1.0 master # create RB_1.0 branch for release
> git checkout RB_1.0 # change working branch to RB_1.0
> git tag 1.0 RB_1.0 # tagged 1.0 to RB_1.0's current status
> git checkout master
> git rebase RB_1.0 # rebase master with RB_1.0
> git branch -d RB_1.0 # delete RB_1.0 branch
> git branch -m oldname newname # rename branch
> git branch RB_1.0.1 1.0 # create branch RB_1.0.1 for tag 1.0
> git archive --format=tar --prefix=mysite-1.0/ 1.0 | gzip > mysite-1.0.tar.gz
マージ
>git merge RB_1.0 # merge RB_1.0 to master(when cuurent branch is master)
競合が生じた場合はソース上に表示される
修正して解消したのちcommitする必要がある
> git cherry-pick 321d.. #merge only 321d.. commit to master
> git mergetool #use when merge conflict
プル
> git pull #fetch repo and merge
> git pull origin RB_0.1 #merge RB_0.1 branch
> git fetch #only fetch
> git remote add # alias name
> git remote #list aliases
> git remote show #show info of alias
> cd /work
> git clone git://github.com/....
No comments:
Post a Comment