是否有可能在过去推送提交树中插入新提交?

时间:2016-08-15 07:27:33

标签: git github

我的git树结构:

* f7b1232 (HEAD -> feature/users-model, origin/feature/users-model) hi
*   e4b0e22 (origin/develop, origin/HEAD, feature/posts, develop) Merge pull request #7 f
rom rightx2/feature/users
|\
| *   19c42fa (origin/feature/users) Merge pull request #6 from rightx2/feature/users-view
| |\
| | * 68e6ffb (origin/feature/users-view) Implement simple message showing mechanism
| | * 211530b Import secret infos from environ variable
| | * a1eebb5 Add login,signup FB link
| | * f41a915 Rule out chacha_dabang from Makefile 'migrate'
| | * 7dc6ba8 Python-Social-Auth : Facebook
| | * e8530c6 Implement logout mechanism
| | * b726d24 Showing user info in header.html
| | * c0b8977 Implement login mechanism
| | * 2d9c8e7 Implement Signup mechanism
| | * 48b74ee Create home view
| | * 0cbea91 Install django-pipeline for managing static files
| | * 187caca Apply static files using load staticfiles
| | * 2ac64bb Remove chacha_dabang from INSTALLED_APPS
| | * 7d6b4ba Create skeleton html
| | * 60e6b15 Create SignupView : render to simple 'signup' text showing page
| |/
| *   9b52f89 Merge pull request #5 from rightx2/feature/users-model
| |\
|/ /
| * 193bf39 Update Makefile : add 'users' in makemigrations
| * 8ece4a4 Create User model inheriting AbstractUser
| * 1ae6a56 Init apps : users
|/
*   4ec18e7 Merge pull request #3 from rightx2/feature/init
|\
| * 96d6b8c (origin/feature/init) Teporarily remove travis
| * c5c9e57 Update requirements(dev) : selenium
| * 2c8f6ee Install Travis in slack
| * 75c8ccb Init travis.yml
| * 54fa188 Create Makefile : migrate
| * d211af7 Add chacha_dabnag in INSTALLED_APPS
| * 3e5601d Install debug_toolbar and django_extension
| * d2a8780 Scaffold settings
| * 2d63194 Update .gitignore : database files
| * 2bfc7c5 Init project : chacha_dabang
| * 4466f58 Init : requirements
|/
* e3a8499 (origin/master, master) Initial commit

目前,我正在f7b1232,我意识到我需要在origin/feature/init分支中添加更多提交(介于75c8ccb2c8f6ee之间)。但是这个分支已经被github推入并合并到其他分支中。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以使用rebase来操纵树。有关详细信息,请查看git-scp page。基本上你可以运行git rebase --interactive SHA并选择提交进行编辑。您还可以重新订购提交,重新编写提交并立即压缩。最后运行git rebase --continue以返回HEAD。

请记住,在master分支和其他人使用的分支上使用树操作不是一个好方法。您应该在顶部添加提交,然后描述为什么需要它。