-
git目录下的文件状态变化图
- 文件状态变化
-
当前工作状态
- 提交后的分支状态,HEAD是我们当前的工作节点
-
分支
-
本地分支
-
切换分支--git checkout xxx分支名
- 1.改变HEAD的指向
- 2.改变工作目录了下所有的文件内容,保持与HEAD指向的节点的所有内容一致
-
3.继续提交后,可能会导致不同的分支
- 切换回主分支后继续开发
- 生成和切换分支,git checkout -b xxx分支名
- 生成分支--git branch xxx分支名
- 删除本地分支--git branch -d xxxname
-
远程分支
- 1.查看所有远程分支信息 git remote -v
- 2.添加远程分支 git remote add (shortName) (Url)
- 3.远程抓取信息 git fetch (shortName)
-
4.查看远程仓库信息 git remote show (shortName)
- 包含较多复杂信息
- 5.本地远程仓库删除 git remote rm (shortName)
- 6.本地远程仓库重命名 git remote rename (shortName)
- 打标签
-
在本地分支上工作的例子
-
1.git branch testing
- 子主题 1
-
2.git checkout testing
- 子主题 1
-
3.some edit and commit on testing
- 子主题 1
-
4.git checkout master
- 子主题 1
-
5.some edit and commit on master
- 子主题 1
-
6.突发事件——需要hotfix
- 子主题 1
-
7.hotfix合并到master
- 子主题 1
-
8.回到testing继续工作
- 子主题 1
-
9.合并master、testing
- 子主题 1
- 子主题 2
-
与远程分支一起工作
-
1.本地状态
- 子主题 1
-
2.some editor and commit
- 子主题 1
-
3.提交之前先fetch
- 子主题 1
-
"小技巧大省事”
-
自动补全
- git-completion.bash
-
放弃本地所有工作,强制与服务器同步
- git reset --hard origin/master
-
理想工作流程
- 子主题 1