什么是合并冲突?
大多数问题都解决了resolving merge conflict
like this https://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git%20%22%22 one.
但我不知道为什么它会发生在我身上......
简而言之,我们被告知:
git clone url ~/lab
现在我们必须编辑这些文件,然后提交更改。
对于第二个任务,我们需要执行以下操作:
git commit -am 'changes to lab1 after handin'
git pull
git checkout -b lab2 origin/lab2
git merge lab1
现在我的伙伴把他的文件发给我lab1
。所以我可以处理他的代码,因为它更干净、更有组织。
git status
>>> nothing to commit, working directory clean
然后我删除所有文件
git status
>>> list of deleted files
git commit -am 'delete my files'
git status
>>> nothing to commit, working directory clean
然后我将他的文件提取到我的目录中
git status
>>> list of untracked files in red
git add .
git status
>>> Changes to be commit and the list of files in green
git commit -am 'teammate files'
git status
>>> nothing to commit, working directory clean
现在TA命令
git commit -am 'changed branch'
git pull
>>> Already up-to-data. (As expected!!)
git checkout -b lab2 origin/lab2
>>> On branch lab2
git merge lab1
>>> almost all files failed merge and have conflict
有什么解释为什么会发生这种情况吗?我怎样才能防止这种情况发生?
我害怕自己这样做,因为我可能会删除不应该删除的代码......所以我宁愿git merge
自己工作。