2016-06-23 4 views
0

をリベース引き起こし説明:平行な2つの歴史 - Gitは問題

私は約2で大学に行くときのためのコードポートフォリオの並べ替えを持っなるように私は戻ってOctober 15, 2015のGit repositoryを作成年。現時点では、pythonUdemyの助けを借りてプログラムする方法を学習していますが、そのコースを修了すると、C++、次にPhpを学習する予定です。しかし明らかに、これはポイントのほかにすべてです。

だから、今日(June 22, 2016)私は私がやって、ちょうど私のコミットをすべて表示するにはgit logを実行するために起こったチュートリアルのいずれかからいくつかのコードを押し上げたように私のGitリポジトリに気づき、このような何かに気づいた:

git commit tree

だから私はread持っているものから、私はこの知見から収集した情報私が何か間違ったことをマージし、そのため、私は上の画像のようなものになってしまっているということです。

私の次のステップは、git rebase -i --rootコマンドを使用して、上の画像の青色のボックスにマークされているすべてのコミットを削除できるかどうかを確認することでした。その時点でそう

2nd error message

、私はちょうどそれがgit rebase --skipを実行して、コミットスキップ:それは15のコミットヒットするまでのコースのどちらが、それは、このようになり、エラーメッセージを吐き出す場所(約)罰金つもりでした。だから、約2以上のコミットは(右キュー上の)ときで行きました:

1st error message

ので、もちろん、私はgit rebase --skipを実行し、ちょうどそれがコミットの残りの部分と仕上げましょう。

これが完了すると、私はちょうどgit rebase --abortを実行しました。その2つのコミットをスキップしたためです。すべての後に私の次のステップは、インターネット上で答えを探し回ることでした。私が見つけることができる唯一の良い答えの一つはhereでした。私はその後答えに従った:

私は、最初に履歴を平坦化して並列履歴を取り除き、マージコミットを削除しようとすることをお勧めします。そして、一度厳密に線形の履歴を取得したら、履歴を書き換えてすべてのデバッグチャーンを削除するように設定できます。

pick 9140277 Initial commit 
pick 95b2f3b Made some minor changes to the code to increase usability 
pick d83b165 Converts the folder to a .tar.bz2 and then deletes the folder 
pick 3b755b3 Removed some blank lines at the bottom of the file 
pick e2f2e3e Added the feature to remove files/folders that are older than a certain age 
pick 86b1115 Finished the backup final ftp script for now 
pick bfbbcd4 Removed text from a variable 
pick 2a7cacd Fixed some minor bugs in the code 
pick a943277 Added some new fetures to the script 
pick b31bf66 Removed some unnecessary lines of code 
pick cc2c9f7 Added Countdown Timers and other help to the portfolio 
pick f443919 Fixed a few if statements 
pick d6588a0 Everything is in working order 
pick f8cc756 Renamed some of the files 
pick 6a859f6 Rename backup final ftp.py to backup ftp v.4 (final).py 
pick 2dcdae3 Deleted an unneeded folder 
pick 0c10370 Added 'Lecture 14 Numbers' 
pick 5358b32 Added 'Remove Numbers v.1.py' 
pick 8b95691 Reorganized the repository 
pick 250f94b Added 'Lecture 16 Strings' 
pick 6ebfd31 Changed the numbering of the files 
pick 1f275e4 Added 'Lecture 19 Print Formatting' 
pick b7d6608 Initial commit 
pick 6718968 Made some minor changes to the code to increase usability 
pick c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder 
pick 19a495f Removed some blank lines at the bottom of the file 
pick c5687a3 Added the feature to remove files/folders that are older than a certain age 
pick 93e9742 Finished the backup final ftp script for now 
pick 589251c Removed text from a variable 
pick 4a7f2d1 Fixed some minor bugs in the code 
pick 4172115 Added some new fetures to the script 
pick 2377980 Removed some unnecessary lines of code 
pick e183900 Added Countdown Timers and other help to the portfolio 
pick dfc9747 Fixed a few if statements 
pick 0fa9983 Everything is in working order 
pick 09abfd7 Renamed some of the files 
pick 051dae3 Rename backup final ftp.py to backup ftp v.4 (final).py 
pick bac2105 Deleted an unneeded folder 
pick e35b6ba Added 'Lecture 14 Numbers' 
pick 60b17e4 Added 'Remove Numbers v.1.py' 
pick c654494 Reorganized the repository 
pick 16e17be Added 'Lecture 16 Strings' 
pick 3f37ca3 Changed the numbering of the files 
pick ab99b1c Added 'Lecture 19 Print Formatting' 
pick 5ea99f2 Added 'Lecture 21 Lists' 
pick b8dba98 Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point 
pick ae50e5b Added 'Lecture 23 Dictionaries' 
pick 3306d23 Added 'Lecture 25 Tuples' 
pick 36e22b5 Added 'Lecture 26 Files' 
pick 2fd3983 Removed a gitignore specifier from the .gitignore file 

唯一の問題はということで:

唯一の問題は、私は、平行履歴を削除し、および/または私はgit rebase -i --rootを実行したときに、私はこのような何かを得るために、マージコミットを削除する方法を見つけ出すことができなかったということでした私はこのように見えると思われるマージは全く見ませんMerge branch 'master' of github.com:Lowe-Man/Portfolio

最後にもう一度質問します。どのように私は、赤い線が消え緑のものを作ることができ、そしてその青いラインのその小さなセクションには、下の画像では、このフルリニア歴史作るために:

linear history

任意の助けをいただければ幸いです。 ありがとう、 アレックス

答えて

1

マージコミットを省略することができます。あなたはgit rebase --onto ab99b1c 5ea99f2^ origin/masterを試すことができます。それが終わると、HEADはあなたが望むものですが、HEAD状態になっている可能性があります。

更新:ケースを簡単にするために、

A--B--M--D--E 
     /
O----P 

は(MはマージがBとPのコミットである)、プレビューは大丈夫に見えます願っています。あなたは今、それはA-B-D'-E'ようなものだMと一緒にO Pを削除し、ちょうどB D E.

git rebase --onto B M E 

を維持したいです。

2を更新:

A-B----M-D 
    \  /
    C--- 

C Aからのものであり、あなたがラインADにCを移動したい場合はMにBをマージし、

git rebase --onto B C^ D 

、他のケースを簡単にするために今、あなたが得ますA-B-C'-D'。 Mはマージコミットであり、削除されました。

更新3:git resetgit cherry-pickを使用して、2回目の更新でジョブを実行します。

git reset B --hard 
#now we get A-B 

git cherry pick C D 
#now we get A-B-C'-D' 
+0

'git rebase --onto ab99b1c 5ea99f2^origin/master'を実行したらどうしますか?申し訳ありません、私はかなりgitに新しいです。 –

+1

@Alexエラーがなければ 'git log --oneline --graph'または' gitk'を実行して、現在の履歴があなたが望むものであるかどうかを確認してください。 – ElpieKay

+0

それは私が欲しいものなのかどうか本当に分かりません。線形履歴を作成するために、すべてのマージコミットを削除したいと思います。 –