1. clone git repository
$ git clone git@10.193.115.240:linux-omap-2.6.git //fetch project from remote2. create new repository
$ git clone <git file path> // e.x. /opt/git/project.git, fetch from local
$ git init #initialize a git database(meta-data) in “.git” directory
$ git remote add origin git@10.193.115.240:test.git # add remote server
$ git add . # add everything under the current directory$ git commit -a -m “some discription”
#before push to sever, check gitosis configuration to confirm you have access right.
$ git push origin master:refs/heads/master
$ ls -l /home/git/repositories/xxx.git #check the access right of xxx.git4. use merge-tool to resolve conflict after merge
$ cd /var/cache/git
$ ln -s /home/git/repositories/xxx.git xxx.git
$ git mergetool5. recovery git-log record that will not modify any source code even you
haven't commit.
$ git reset --soft <version_number>6. recovery git-log record and source code to before version.
$ git reset --hard <version_number>
7. look up the difference between the latest commit version and latest second commit version
$ git diff HEAD^18. update branch info on remote server
$ git remote update9. push(fetch) codes that's the head version of a branch to server(local)
$ git push(fetch) origin <branch-name>:refs/heads/<branch-name>
10. merge some commit in other branch to the current branch that you currently work with.
$git cherry-pick <Commit-ID>
Delete Branch on Server
1. delete the local branch that you want to delete
git-branch -D <branch>
2. delete the remote branch through git-push
git push --force origin : <branch>
Git Tag related command
1. list all tags
$ git tag
2. Search specific tags
$ git tag -l 'v4.0.*'
3.1 Create tag
$ git tag -a <Tag-Name> -m <Tag-Description>
3.2
$ git tag <Tag-Name>
4. Use "--tags" parameter to upload all tags to git server
$ git push origin --tags
Git 基本環境設定, 主要是設定自己帳號下的環境參數.
基本資料設定
直接於 Shell 下執行下述 (p.s. 這些設定會在 ~/ 下產生 .gitconfig ):
1. Configs user's account
$ git config --global user.name "<name>"2. Configs user's email
$ git config --global user.email "<email>"
3. git diff 要顯示顏色
$ git config --global color.diff auto
4. git status 要顯示顏色
$ git config --global color.status auto
5. git branch 要顯示顏色
$ git config --global color.branch auto
沒有留言:
張貼留言