git (四) work flow

工作流

个人工作流
团体工作流

1. pull
2. add
// 修改错误
3. pull
// 修改冲突
4. commit
// 修改错误
5. push // 如果push不上去,pull下来,然后merge,再次push
  • 本地仓库和工作区之间
本地仓库->工作区
	修改
工作区 -> 本地仓库
	git restore  file
	git checkout -- file// git checkout  file 会优先切换到file 分支,如果没有file分支,则做 git checkout -- file 

区别
	git diff file
  • 工作区 与 暂存区 之间
工作区 -> 暂存区
	git add file
	git rm file
暂存区 -> 工作区 
	git restore --staged

区别
	git diff --cached
  • 暂存区 与 本地仓库 之间
暂存区 -> 本地仓库
	git commit -m "b"
本地仓库  -> 暂存区
	git reset --soft HEAD^1
  • 本地仓库 与 本地仓库 之间
本地仓库(high commit id)  -> 本地仓库(low commit id)
	git reset --hard HEAD^1 // 回退一次提交 . 注意:会导致 workspace  清空
	git reset --hard commit_id //回退到 commit_id 注意:会导致 workspace  清空
  • local repository 与 remote repository 之间
local repository -> remote repository
	git push origin master // origin 为 仓库的名称,master为本地分支的名称
remote repository ->  local repository
	git pull
	git fetch

库间的关联
	git remote remove origin
	git remote add origin url

在这里插入图片描述

pull 时的冲突
pull 时的冲突
	1. 工作区的冲突(与远程仓库)
	Please move or remove them before you merge. // 需要手动处理
	//move 即可
	2. 暂存区的冲突(与远程仓库)
	Please commit your changes or stash them before you merge. // 需要手动处理
	// stash 或者 commit 即可(不过commit了之后会产生情况3)
	3.1. 本地仓库的冲突(与远程仓库)
		3.1 CONFLICT (add/add): Merge conflict in file_xxx
			Auto-merging file_xxx
			Merge made by the 'recursive' strategy.
			
			弹出一个vim窗口,让你输入 merge 信息.(该窗口中的非#开头的都是merge信息)
			这次vim窗口关闭后,会创建一个提交,这次提交是一次merge

		3.2 CONFLICT (add/add): Merge conflict in file_xxx // 需要手动处理
			Auto-merging file_xxx
			Automatic merge failed; fix conflicts and then commit the result.

			On branch master
			Your branch and 'origin/master' have diverged,
			and have 1 and 2 different commits each, respectively.
			  (use "git pull" to merge the remote branch into yours)

			You have unmerged paths.
			  (fix conflicts and run "git commit")
			  (use "git merge --abort" to abort the merge)

			Unmerged paths:
			  (use "git add <file>..." to mark resolution)
			        both added:      file_xxx

			cat file_xxx // aaa 是本地仓库上的,bbb是远程仓库的
			<<<<<<< HEAD
			aaa
			=======
			bbb
			>>>>>>> f48bced1363868fa834c814e393e492c06fe01b6


			修改掉 <<>> ,然后 git add 和 git commit
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值