Git使用

2017-10-20  本文已影响0人  ToFlyBear

http://www.ruanyifeng.com/blog/2014/06/git_remote.html

http://nvie.com/posts/a-successful-git-branching-model/

http://insights.thoughtworkers.org/gitflow-consider-harmful/

git 基本命令
http://www.cnblogs.com/cspku/articles/Git_cmds.html
http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html
fetch 是从remote取到repo,不会自动合并改动
pull 是从remote 取到当前branch , 合并改动

repo init
repo init -u ssh://<USERNAME>@IP:PORT/<PATH_TO_MANIFEST_PROJECT> -b <MANIFEST_REVISION> -m <MANIFEST_NAME>

repo sync

$ repo sync or
$ repo sync [<PROJECT_LIST>]

创建新分支:git branch branchName
切换到新分支:git checkout branchName
上面两个命令也可以合成为一个命令:
git checkout -b branchName

git checkout master //取出master版本的head。
git checkout tag_name //在当前分支上 取出 tag_name 的版本
git checkout master file_name //放弃当前对文件file_name的修改
git checkout commit_id file_name //取文件file_name的 在commit_id是的版本。commit_id为 git commit 时的sha值。
git checkout -b dev/1.5.4 origin/dev/1.5.4 //从远程dev/1.5.4分支取得到本地分支/dev/1.5.4

新建一个分支,与指定的远程分支建立追踪关系

$ git branch --track [branch] [remote-branch] 这个意思是建立branch之间关系 一般git branch前提是你在一个branch上 再建branch就是基于当前branch, 加上--track就可以改变新branch 基于的branch位置

branch view
git branch -av
branch delete
git branch -d <BRANCH_NAME> //-D 直接删 -d 会check 是否又改动

git pull rebase XXX(remote branch) 解决是 当前branch commit后 remote又有commit,
通过pull + rebase 将remote commit 和当前branch commit 合并起来
= git fetch then git rebase XXX

git checkout -b [your branch name] --track [remote branch name]

git push [remote name] HEAD: [branch_name]
git push [remote name] HEAD:refs/for/[branch_name]

上一篇 下一篇

猜你喜欢

热点阅读