2016-09-26 4 views
0

私は別のレポでチェックアウトされたブランチBを持っていて、そこではいくつかの変更が行われましたが、リベース後には--forceでpush'edされましたコミット)。 変更されたブランチを最初のリポジトリにプルすると、コンフリクトがマージされます。次のように私は(実際の出力を簡素化無関係な変更、で)実行rebaseの結果がコンフリクトをマージした後にプル

コマンドは次のとおりです。

# First checkout the original B 
$ pwd 
/home/user/dir1 

$ git checkout B 
Switched to branch 'B' 
Your branch is up-to-date with 'origin/B'. 

# Now clone the same repo into another directory and checkout B there 
$ cd .. && git clone git clone ssh://[email protected]/myrepo.git dir2 && cd dir2 

$ git checkout B 
Switched to branch 'B' 
Your branch is up-to-date with 'origin/B'. 

# Now edit some file, commit it and "merge" the changes 
# to the originally last commit as a fixup 
$ nano file.txt 
$ git commit -a -m "Fixup to file.txt" 
$ git rebase -i HEAD~2 
... the last commit is "fixup'ed" to the last commit in the original branch (the commit before "Fixup to the file.txt" commit 

# Push the B with rewritten history to the upstream 
$ git push --force origin B 

# Get back to the original repo and pull the changes 
$ cd ../dir1 
$ git pull origin B 
... 
CONFLICT (content): Merge conflict in .../file.txt 
... 

枝の2つのコピー間の唯一の違いは、「トップ」にコミットしています。 gitに、最初のリポジトリの最後のコミットを、上流にあるgit-pullなしで、対応するファイルの変更を内部で調べようとしているものに置き換えたいのですか?

Edir/にそのままコミットされ
...-A-B-C-D-E  # HEAD 

のような歴史を持つ

+0

あなたは質問を言い換えると、枝、リモコンや重要なコミットの名前を使用することはできますか? –

答えて

0

Eに由来するコミットとしてE'を導入しますが、リベースされてdir2から強制的にプッシュされました。 dir

あなたがコミットする前に上にあるように、あなたのHEADを巻き戻すことができます。

があったものは何でもあなたを与えるだろう

git reset --hard HEAD^ 

...-A-B-C-D  # HEAD 
      \ 
      `-E # dangling and invisible, will be garbage collected 

その後

git pull upstream B 

を取得します

...-A-B-C-D-E'  # HEAD 
      \ 
      `-E # dangling and invisible, will be garbage collected 

はあなたがEの内容を失うことになる、しかし注意して(あなたがreflogでそれを検索しない限り)

+0

さて、問題の内容はすべて2番目のコピーの上流にプッシュされました。したがって、私が必要とするのは、第2ブランチと同じブランチで同じデータを取得することだけです。 – Student4K

+0

多分私はあなたの質問に誤解しました。私の他のコメントを参照してください。 –

関連する問題