git rebase
在文件被添加到存儲庫,然後從存儲庫中刪除,然後添加到工作目錄(但不是存儲庫)的某些情況下似乎無法正常工作。git rebase,「會被覆蓋」,「沒有變化 - 你忘了使用'git add'嗎?」
這裏是我的問題更具體的描述:
如果創建,並從一些 幹線切換到一個分支,
和文件X添加和分支致力於 ,
並且隨後X被移除並且 在分支中提交,
和X在工作 目錄下重新創建的,但不能添加或 承諾,
和主幹分支進步,
然後
採用了先進的 衍合進行幹線作爲基地將失敗,因爲 它會拒絕覆蓋X,
和rebas e不能繼續 ,即使工作目錄X是 已移除或移除。
以下腳本複製在命令行上我的問題:
git init
echo foo > foo.txt
git add .
git commit -m 'foo'
echo foo >> foo.txt
git add .
git commit -m 'foo foo'
git checkout -b topic HEAD^
git log
echo bar > bar.txt
echo baz > baz.txt
git add .
git commit -m 'bar baz'
git rm bar.txt
git commit -m '-bar'
echo bar > bar.txt
git rebase master
# the following output is emitted:
# First, rewinding head to replay your work on top of it...
# Applying: bar baz
# Using index info to reconstruct a base tree...
# Falling back to patching base and 3-way merge...
# error: Untracked working tree file 'bar.txt' would be overwritten by merge. Aborting
# Failed to merge in the changes.
# Patch failed at 0001 bar baz
#
# When you have resolved this problem run "git rebase --continue".
rm bar.txt
git rebase --continue
# the following output is emitted:
# Applying: bar baz
# No changes - did you forget to use 'git add'?
#
# When you have resolved this problem run "git rebase --continue".
# If you would prefer to skip this patch, instead run "git rebase --skip".
# To restore the original branch and stop rebasing run "git rebase --abort".
我知道我可以放棄使用git rebase --abort
底墊,去除bar.txt
,然後再git rebase master
。但是,我怎樣才能在不墮落的情況下繼續進行重組?
我建議使用'git-apply',因爲'patch'不支持Git二進制diff格式。 – 2015-02-14 01:16:38