简体   繁体   English

为什么我的提交历史记录看起来像这样,我该如何解决呢?

[英]Why does my commit history look like this and how can I go about fixing it?

So for the past few days, I have been trying to figure out why my git commit history looks something like this where my commit history is not linear like I would like it to be? 因此,在过去的几天里,我一直在试图弄清为什么我的git提交历史看起来像这样,而我的提交历史却不是我想要的那样线性? I have tried many things to try to get this so called flattened out but to no avail. 我已经尝试了很多方法来尝试将其称为“ 扁平化”,但无济于事。

If anybody out there could help that would be greatly appreciated. 如果有人可以帮助您,将不胜感激。

View from git log --oneline --graph command in git bash 从git bash中的git log --oneline --graph命令查看

查看1

View from git log with in SmartGit SmartGit中使用 git log查看

查看2

Here is the error that I got after I ran git rebase 0fa9983894820ac8062a7413188e4ea2bc28089b 这是我运行git rebase 0fa9983894820ac8062a7413188e4ea2bc28089b后遇到的错误

错误

Check out my ugly tree: 看看我的丑树:

* 8d61057 (HEAD -> master) file4
*   61795ae Merge branch 'new'
|\  
| * 56f104d file2
* | 2484695 file3
|/  
* ecc3f4f init

Notice that 61795ae Merge branch 'new' introduces nothing new, but is merely a merge commit. 请注意, 61795ae Merge branch 'new'引入任何新内容,而仅仅是合并提交。

I can get my trunk back in a straight line with rebase from the last commit before the split. 从拆分之前的最后一次提交开始,我可以使树干恢复直线并重新设置rebase

git rebase ecc3f4f

Now the tree is all straight again 现在树又直了

* e794681 (HEAD -> master) file4
* b65595a file3
* 3d6ffe9 file2
* ecc3f4f init

Explanation 说明

After cloning your project, I wanted to take a look at the commits to see the conflict. 克隆您的项目后,我想看一下提交以查看冲突。

You renamed this backup script. 您重命名了此备份脚本。

051dae3 Rename backup final ftp.py to backup ftp v.4 (final).py
Backup scripts/backup final ftp.py → Backup scripts/backup ftp v.4 (final).py

But at the same time in another clone of this repository, you moved this backup script into a "Python" folder with a group of others 但是与此同时,在此存储库的另一个克隆中,您将此备份脚本与其他一组脚本一起移动到了“ Python”文件夹中

09abfd7 Renamed some of the files
Backup scripts/backup final ftp.py → Python/Backup scripts/backup final ftp.py

Now to resolve this conflict, you had to clean it up with two commits. 现在要解决此冲突,您必须通过两次提交将其清除。

The first one just to get the file out of the right folder to the wrong folder with the right name. 第一个只是将文件从正确的文件夹中移到名称正确的错误文件夹中。

8006e70 Renamed some files
Python/Backup scripts/backup final ftp.py → Backup scripts/backup ftp v.4 (final).py

Then you just lost that file with the "unneeded folder" 然后,您只是使用“不需要的文件夹”丢失了该文件

bac2105 Deleted an unneeded folder
deleted Backup scripts/backup ftp v.4 (final).py

Basically, it was a matter of checking out those two commits, resetting them softly to the staging area, and committing them all in one. 基本上,这是检查这两个提交,将它们轻柔地重置到登台区域并全部提交的问题。

Then cherry-pick the rest. 然后选择其余部分。 You can clone the straight master branch here 您可以在此处克隆直接主分支

Procedure 程序

git clone https://github.com/Lowe-Man/Portfolio

cd Portfolio/

git log --graph --oneline --decorate --all
 * de71d41 (HEAD -> master, origin/master, origin/HEAD) Removed a gitignore specifier from the .gitignore file * f80eb5c Added 'Lecture 26 Files' * 505478e Added 'Lecture 25 Tuples' * 632a2f3 Added 'Lecture 23 Dictionaries' * 990d74e Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point * bb213ac Added 'Lecture 21 Lists' * ab99b1c Added 'Lecture 19 Print Formatting' * 3f37ca3 Changed the numbering of the files * 16e17be Added 'Lecture 16 Strings' * c654494 Reorganized the repository * 60b17e4 Added 'Remove Numbers v.1.py' * e35b6ba Added 'Lecture 14 Numbers' * bac2105 Deleted an unneeded folder * 8006e70 Renamed some files |\\ | * 051dae3 Rename backup final ftp.py to backup ftp v.4 (final).py * | 09abfd7 Renamed some of the files |/ * 0fa9983 Everything is in working order * dfc9747 Fixed a few if statements * e183900 Added Countdown Timers and other help to the portfolio * 2377980 Removed some unnecessary lines of code * 4172115 Added some new fetures to the script * 4a7f2d1 Fixed some minor bugs in the code * 589251c Removed text from a variable * 93e9742 Finished the backup final ftp script for now * c5687a3 Added the feature to remove files/folders that are older than a certain age * 19a495f Removed some blank lines at the bottom of the file * c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder * 6718968 Made some minor changes to the code to increase usability * b7d6608 Initial commit 
git checkout 051dae3

git reset --soft HEAD~

git status
 HEAD detached from 051dae3 Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: Backup scripts/backup final ftp.py -> Backup scripts/backup ftp v.4 (final).py 
git checkout 09abfd7

git reset --soft HEAD~

git status
 HEAD detached from 09abfd7 Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: Backup scripts/backup ftp v.4 (final).py renamed: Backup scripts/backup final ftp.py -> Python/Backup scripts/backup final ftp.py renamed: Backup scripts/backup ftp v.1.py -> Python/Backup scripts/backup ftp v.1.py renamed: Backup scripts/backup ftp v.2.py -> Python/Backup scripts/backup ftp v.2.py renamed: Backup scripts/backup ftp v.3.py -> Python/Backup scripts/backup ftp v.3.py new file: Python/Backup scripts/backup local.py renamed: Countdown Timers/Countdown Timer (Cleaned).py -> Python/Countdown Timers/Countdown Timer v.2.py new file: Python/Countdown Timers/Countdown Timer v.3 (final).py renamed: Countdown Timers/Coutdown Timer.py -> Python/Countdown Timers/Coutdown Timer (original).py renamed: Countdown Timers/Coutdown Timer (Improved).py -> Python/Countdown Timers/Coutdown Timer v.1.py renamed: Help/How to remove zeros.py -> Python/Help/How to remove zeros.py renamed: Help/Timezone.py -> Python/Help/Timezone.py renamed: Countdown Timers/length.py -> Python/Help/length.py 

Ditch the extra copy, and move the correctly named one into the Python folder. 放弃多余的副本,然后将正确命名的副本移到Python文件夹中。

rm 'Python/Backup scripts/backup final ftp.py'

mv 'Backup scripts/backup ftp v.4 (final).py' 'Python/Backup scripts/backup ftp v.4 (final).py'

git add .

git status
 HEAD detached from 09abfd7 Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: Backup scripts/backup ftp v.1.py -> Python/Backup scripts/backup ftp v.1.py renamed: Backup scripts/backup ftp v.2.py -> Python/Backup scripts/backup ftp v.2.py renamed: Backup scripts/backup ftp v.3.py -> Python/Backup scripts/backup ftp v.3.py renamed: Backup scripts/backup final ftp.py -> Python/Backup scripts/backup ftp v.4 (final).py new file: Python/Backup scripts/backup local.py renamed: Countdown Timers/Countdown Timer (Cleaned).py -> Python/Countdown Timers/Countdown Timer v.2.py new file: Python/Countdown Timers/Countdown Timer v.3 (final).py renamed: Countdown Timers/Coutdown Timer.py -> Python/Countdown Timers/Coutdown Timer (original).py renamed: Countdown Timers/Coutdown Timer (Improved).py -> Python/Countdown Timers/Coutdown Timer v.1.py renamed: Help/How to remove zeros.py -> Python/Help/How to remove zeros.py renamed: Help/Timezone.py -> Python/Help/Timezone.py renamed: Countdown Timers/length.py -> Python/Help/length.py 

In addition to everything else we renamed, the staged resolution of interest is: 除了我们重命名的所有其他内容之外,感兴趣的分阶段解决方案是:

  renamed: Backup scripts/backup final ftp.py -> Python/Backup scripts/backup ftp v.4 (final).py 

Make a new commit using the same message. 使用相同的消息进行新的提交。

git commit -c ORIG_HEAD

git log --graph --oneline --decorate --all
 * 1cc1b2c (HEAD) Renamed some of the files | * de71d41 (origin/master, origin/HEAD, master) Removed a gitignore specifier from the .gitignore file | * f80eb5c Added 'Lecture 26 Files' | * 505478e Added 'Lecture 25 Tuples' | * 632a2f3 Added 'Lecture 23 Dictionaries' | * 990d74e Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point | * bb213ac Added 'Lecture 21 Lists' | * ab99b1c Added 'Lecture 19 Print Formatting' | * 3f37ca3 Changed the numbering of the files | * 16e17be Added 'Lecture 16 Strings' | * c654494 Reorganized the repository | * 60b17e4 Added 'Remove Numbers v.1.py' | * e35b6ba Added 'Lecture 14 Numbers' | * bac2105 Deleted an unneeded folder | * 8006e70 Renamed some files | |\\ | | * 051dae3 Rename backup final ftp.py to backup ftp v.4 (final).py | |/ |/| | * 09abfd7 Renamed some of the files |/ * 0fa9983 Everything is in working order * dfc9747 Fixed a few if statements * e183900 Added Countdown Timers and other help to the portfolio * 2377980 Removed some unnecessary lines of code * 4172115 Added some new fetures to the script * 4a7f2d1 Fixed some minor bugs in the code * 589251c Removed text from a variable * 93e9742 Finished the backup final ftp script for now * c5687a3 Added the feature to remove files/folders that are older than a certain age * 19a495f Removed some blank lines at the bottom of the file * c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder * 6718968 Made some minor changes to the code to increase usability * b7d6608 Initial commit 

Now we've effectively combined commits 051dae3 , 8006e70 , and bac2105 into 09abfd7 as a new commit 1cc1b2c which is the way I think it should have functionally been committed in the first place. 现在,我们已经有效地结合起来提交051dae38006e70bac210509abfd7作为一个新的提交1cc1b2c这是我觉得它应该是功能摆在首位犯下的方式。

So all that's left is to cherry-pick the rest of the tree starting from e35b6ba Added 'Lecture 14 Numbers' 所以剩下的就是从e35b6ba Added 'Lecture 14 Numbers'开始挑选其余的树。 e35b6ba Added 'Lecture 14 Numbers'

git cherry-pick e35b6ba^..de71d41

git log --graph --oneline --decorate --all
 * 0e52036 (HEAD) Removed a gitignore specifier from the .gitignore file * 1cf948b Added 'Lecture 26 Files' * 62a1602 Added 'Lecture 25 Tuples' * aeb7421 Added 'Lecture 23 Dictionaries' * d47635d Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point * d54141c Added 'Lecture 21 Lists' * 66174f2 Added 'Lecture 19 Print Formatting' * 3969da2 Changed the numbering of the files * 9c4828c Added 'Lecture 16 Strings' * ce159a3 Reorganized the repository * 759e08b Added 'Remove Numbers v.1.py' * 323be27 Added 'Lecture 14 Numbers' * 1cc1b2c Renamed some of the files | * de71d41 (origin/master, origin/HEAD, master) Removed a gitignore specifier from the .gitignore file | * f80eb5c Added 'Lecture 26 Files' | * 505478e Added 'Lecture 25 Tuples' | * 632a2f3 Added 'Lecture 23 Dictionaries' | * 990d74e Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point | * bb213ac Added 'Lecture 21 Lists' | * ab99b1c Added 'Lecture 19 Print Formatting' | * 3f37ca3 Changed the numbering of the files | * 16e17be Added 'Lecture 16 Strings' | * c654494 Reorganized the repository | * 60b17e4 Added 'Remove Numbers v.1.py' | * e35b6ba Added 'Lecture 14 Numbers' | * bac2105 Deleted an unneeded folder | * 8006e70 Renamed some files | |\\ | | * 051dae3 Rename backup final ftp.py to backup ftp v.4 (final).py | |/ |/| | * 09abfd7 Renamed some of the files |/ * 0fa9983 Everything is in working order * dfc9747 Fixed a few if statements * e183900 Added Countdown Timers and other help to the portfolio * 2377980 Removed some unnecessary lines of code * 4172115 Added some new fetures to the script * 4a7f2d1 Fixed some minor bugs in the code * 589251c Removed text from a variable * 93e9742 Finished the backup final ftp script for now * c5687a3 Added the feature to remove files/folders that are older than a certain age * 19a495f Removed some blank lines at the bottom of the file * c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder * 6718968 Made some minor changes to the code to increase usability * b7d6608 Initial commit 

Now we can delete our old master branch, use this one as the new master, and force push to the remote. 现在,我们可以删除旧的master分支,将此分支用作新的master,然后强制推送到远程。

git branch -d master

git checkout -b master

git push origin master --force

git log --graph --oneline --decorate --all
 * 0e52036 (HEAD -> master, origin/master, origin/HEAD) Removed a gitignore specifier from the .gitignore file * 1cf948b Added 'Lecture 26 Files' * 62a1602 Added 'Lecture 25 Tuples' * aeb7421 Added 'Lecture 23 Dictionaries' * d47635d Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point * d54141c Added 'Lecture 21 Lists' * 66174f2 Added 'Lecture 19 Print Formatting' * 3969da2 Changed the numbering of the files * 9c4828c Added 'Lecture 16 Strings' * ce159a3 Reorganized the repository * 759e08b Added 'Remove Numbers v.1.py' * 323be27 Added 'Lecture 14 Numbers' * 1cc1b2c Renamed some of the files * 0fa9983 Everything is in working order * dfc9747 Fixed a few if statements * e183900 Added Countdown Timers and other help to the portfolio * 2377980 Removed some unnecessary lines of code * 4172115 Added some new fetures to the script * 4a7f2d1 Fixed some minor bugs in the code * 589251c Removed text from a variable * 93e9742 Finished the backup final ftp script for now * c5687a3 Added the feature to remove files/folders that are older than a certain age * 19a495f Removed some blank lines at the bottom of the file * c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder * 6718968 Made some minor changes to the code to increase usability * b7d6608 Initial commit 

With providing your source code, I was able to do the following steps to your current repo, with @jpaugh 's answer in mind, In order to get the exact same code as you began with. 通过提供您的源代码,我能够对当前的回购执行以下步骤,并牢记@jpaugh的答案,以便获得与开始时完全相同的代码。 The reason you are having trouble with @jpaugh 's answer is because we have remove/remove merge conflicts that we have to manual resolve. 您在@jpaugh的答案上遇到麻烦的原因是因为我们有必须手动解决的删除/删除合并冲突。

Because you already resolved this merge conflict, we are going to do exactly what you did to resolve it the first time. 由于您已经解决了此合并冲突,因此我们将完全按照您第一次解决的方式进行操作。

Grab the branch you want to change the history of. 抓住要更改其历史记录的分支。

git checkout origin/master

We are going to rebase a commit that is before your merge. 我们将为您合并之前的提交提供rebase By default, rebase doesn't preserve merge history, so this will replay your work linearly from that commit to where your origin/master is. 默认情况下,rebase不会保留合并历史记录,因此这将从提交到原始/母版所在的位置线性地重放您的工作。

git rebase 0fa9983

But we have some problems. 但是我们有一些问题。 The merge in history has a remove/remove conflict that you had resolved. 历史记录中的合并具有已解决的删除/删除冲突。 Let's add the changes you made in the resolve commit 8006e70 and the branch 051dae3 to mimic that you made them immediately following the other branch, not in parallel. 让我们添加您在resolve commit 8006e70和分支051dae3以模仿您在另一个分支之后而不是并行进行的情况。

git checkout 8006e70 Backup\ scripts/backup\ ftp\ v.4\ \(final\).py
git rm Backup\ scripts/backup\ final\ ftp.py
git rm Python/Backup\ scripts/backup\ final\ ftp.py

So now we are going to commit our changes as a new commit, but let's use the C tag to give it the same commit message as the merged commit we are replacing. 因此,现在我们将更改作为新的提交提交,但让我们使用C标签为它提供与要替换的合并提交相同的提交消息。 Use the hash of the branch we want the message from. 使用我们希望消息来自的分支的哈希值。

git commit -C 051dae3

Let's use the continue command, to continue rebasing. 让我们使用continue命令,继续进行基础调整。

git rebase --continue

We have a new problem, and that is we merged two commits into one (the merge and branch). 我们有一个新问题,那就是我们将两个提交合并为一个(合并和分支)。 It is still trying to be played out in continuing the rebase. 它仍在尝试继续进行重新设置。 If we had used the -i tag for our original rebase command, we could have indicated we should skip this commit, but this example is all command line. 如果我们在原始rebase命令中使用了-i标记,则可以表明我们应该跳过此提交,但是此示例是所有命令行。 We are going to skip it here. 我们将在这里跳过它。 It failed here because all the changes that it made have already happened. 它在这里失败了,因为它所做的所有更改都已经发生。 We chose to have the commit message in the branch, not the short renamed some files message, so your intentions are clear when you look at our new history. 我们选择在分支中添加提交消息,而不是将短消息renamed some files消息,因此当您查看我们的新历史记录时,您的意图很明确。 Go ahead and skip this conflict, allowing the rebase to continue through the rest of history. 继续并跳过此冲突,从而使重新设置可以在整个历史记录中继续进行。

git rebase --skip

We don't have any more rebasing left. 我们没有更多的基础了。 The function has exited. 该功能已退出。 Now we have a detached head that has a linear commit history. 现在,我们有了一个具有线性提交历史记录的分离头。 Let's check if we succeeded in recreating history, but keeping the files the same. 让我们检查一下是否成功重新创建了历史记录,但文件保持不变。

git diff origin/master

The last diff shows there are no changes to your files, just the history. 最后一个差异显示文件没有更改,只有历史记录。 This produces the following history: 这将产生以下历史记录:

$ git log --oneline --graph
* e8eec78 Removed a gitignore specifier from the .gitignore file
* 2d51522 Added 'Lecture 26 Files'
* 93f6908 Added 'Lecture 25 Tuples'
* 2b3d9c5 Added 'Lecture 23 Dictionaries'
* a8bcfaa Reorganized/Fixed all of the code/comments on all of the lectures that I have done up to this point
* f3d0448 Added 'Lecture 21 Lists'
* 7ce1af4 Added 'Lecture 19 Print Formatting'
* 740f459 Changed the numbering of the files
* da6f679 Added 'Lecture 16 Strings'
* 2d4abf6 Reorganized the repository
* 1d88453 Added 'Remove Numbers v.1.py'
* 85cda36 Added 'Lecture 14 Numbers'
* 3d89d1a Deleted an unneeded folder
* bc41dc6 Rename backup final ftp.py to backup ftp v.4 (final).py
* 52a1354 Renamed some of the files
* 0fa9983 Everything is in working order
* dfc9747 Fixed a few if statements
* e183900 Added Countdown Timers and other help to the portfolio
* 2377980 Removed some unnecessary lines of code
* 4172115 Added some new fetures to the script
* 4a7f2d1 Fixed some minor bugs in the code
* 589251c Removed text from a variable
* 93e9742 Finished the backup final ftp script for now
* c5687a3 Added the feature to remove files/folders that are older than a certain age
* 19a495f Removed some blank lines at the bottom of the file
* c2c58c3 Converts the folder to a .tar.bz2 and then deletes the folder
* 6718968 Made some minor changes to the code to increase usability
* b7d6608 Initial commit

Notice how the commit hashes have changed? 请注意提交哈希如何更改? This is because the history has changed. 这是因为历史已经改变。 If you want to propagate this back to your origin/master, you need to force it. 如果您想将此传播回原点/原件,则需要强制执行。 This is because pushes fail if the history hashes don't match, and we just changed the majority of our history hashes. 这是因为如果历史哈希值不匹配,则推送失败,而我们只是更改了大多数历史哈希值。

Do git push --force origin/master if you want to propagate those changes upstream. 如果要向上游传播这些更改,请执行git push --force origin/master

Remember that other people could have forked your remote if it is public facing, and that it is best practise to not change git history if others have access to those commits. 请记住,如果您的遥控器是面向公众的,那么其他人可能会分叉您的遥控器,并且最佳做法是,如果其他人可以访问这些提交,则不要更改git历史记录。

$ git --version
git version 2.9.0

The reason your history is like this is because you created a new branch at some point, then merged it back in. (Or someone else did.) 您的历史记录之所以这样,是因为您在某个时候创建​​了一个新分支,然后将其合并回去。(或其他人这样做了)。

If you're using GitHub, then it could also mean you accepted a pull-request, which is tantamount to a merge. 如果您使用的是GitHub,则也可能意味着您接受了请求请求,这等同于合并。 If so, there is no way around this, in general. 如果是这样,通常将无法解决此问题。 From their point of view, this is a reasonable choice, as merging is more robust than rebasing, and preserves authorship changes better: we just have to live with uglier log output. 从他们的角度来看,这是一个合理的选择,因为合并比重新部署更可靠,并且可以更好地保留作者更改:我们只需要使用难看的日志输出即可。 In that case, you can stop reading here. 在这种情况下,您可以在这里停止阅读。


I don't know of an automated way to change this, but I can show you how to rebase your commits to the way you want. 我不知道自动更改此方法的方法,但是我可以向您展示如何将提交重新rebase为所需的方法。 That involves rewriting the history from the point of the mistake all the way to the HEAD , creating different commits with the same content. 这涉及从错误的位置一直到HEAD重写历史记录,创建具有相同内容的不同提交。

However, I noticed that the branch you're looking at is not a local branch, but the origin branch for your local copy (assuming usual Git convention here). 但是,我注意到您正在查看的分支不是本地分支,而是本地副本的origin分支(假设此处使用常规的Git约定)。 I understand the desire for clean and pretty log output, however, there is a practical reason not to rebase old history: 我了解对干净和漂亮的日志输出的渴望,但是,有一个实际的理由不重新建立旧的历史记录:

Warning: Although it is possible to rebase your commits locally , it is not a good idea to push such changes to a public project. 警告:尽管可以在本地重新构建提交,但将此类更改推送到公共项目不是一个好主意。 Rebasing your history always causes problems for others with whom you've shared the unmodified history. 对您的历史进行基础调整总是会给与您共享未修改历史的其他人带来麻烦。 So, anyone else involved with your project will be hosed. 因此,与您的项目有关的任何其他人都将被抽水。


With that warning, here goes: 有了该警告,这里是:

  1. First, make a copy of your repository, so that you have a backup. 首先,制作您的存储库的副本,以便进行备份。 (A rebase command never loses data, but if you're unfamiliar with the rebase command, it can be hard to get back to a known state if you make a mistake or change your mind.) (rebase命令永远不会丢失数据,但是如果您不熟悉rebase命令,那么如果您犯了错误或改变了主意,可能很难回到已知状态。)
  2. Check out a new branch based on origin/master , since you can't modify it directly ( git checkout -b new-master origin/master ) git checkout -b new-master origin/master出一个基于origin/master的新分支,因为您不能直接修改它( git checkout -b new-master origin/master
  3. Next, do a git rebase --interactive <commitish> where <commitish> identifies the commit labeled "Everything is in working order" (0fa9). 接下来,执行git rebase --interactive <commitish> ,其中<commitish>标识标记为“一切正常”的提交(0fa9)。
  4. The rebase operation will now open up in your editor, for your approval. 现在,将在您的编辑器中打开重新设置操作,以供您批准。
  5. The first line will be the one called "Renamed some of the files" (09ab). 第一行是名为“重命名某些文件”(09ab)的行。 Change its action from pick to edit . 将其操作从“ pick更改为“ edit
  6. Save the file and close it. 保存文件并关闭它。 The rebase operation will begin. 变基操作将开始。
  7. When the rebase stops after the first commit, git cherry-pick <commitish> where <commitish> describes the commit called "Rename backup file ftp.py to ...". 当第一次提交后重新设置停止时, git cherry-pick <commitish>其中<commitish>描述了称为“将备份文件ftp.py重命名为...”的提交。
  8. git rebase --continue
  9. Verify the results. 验证结果。 You'll notice that every commit has a different ID now, despite having the same description, and same content (diff). 您会注意到,尽管具有相同的描述和相同的内容(diff),但每个提交现在都具有不同的ID。 This is because you have written a new history with the old changes. 这是因为您用旧的更改写了新的历史记录。 The commit date will have changed, but not the authorship date. 提交日期将更改,但作者日期不会更改。

Now, if you want to inflict others with your new history, you can do so by pushing these changes to your origin repository: 现在,如果您想用新的历史记录来侵犯他人,可以通过将以下更改推送到origin存储库中来实现:

$ git push --force origin/master

The --force is required because this will overwrite the existing branch, and invalidate any branches made from that, including the local repository of all contributors. 之所以需要--force是因为它将覆盖现有分支,并使由此产生的任何分支(包括所有贡献者的本地存储库)无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM