向GIT存储库推送一个修订版 [英] Pushing just one revision to GIT repository

查看:87
本文介绍了向GIT存储库推送一个修订版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中工作,当我做出一个改变,我承诺它。然后,在提交3或4次更改后,我将其全部推送。



我想要做的是仅推送其中一个本地修订。我可以那样做吗?如何?



谢谢

解决方案

尝试在本地工作'分支。这有一些优点,例如,如果你打电话来处理错误,你可以切换到另一个分支。

当你准备推送:git checkout master,git pull,git merge work,git push,将会是你的正常流程。然而,你可以从你的工作分支挑选提交给主人,这样只有那些提交将被推送。

  git checkout master 
git cherry-pick <您要提交的id>>
git push

即使您现在也可以这样做。

  git checkout -b工作
git log(并查找您想要的提交的ID)
git checkout master
git reset --hard HEAD〜3(删除最后3次提交)
git cherry-pick<您要提交的ID>
git push


i am working in a project and as i make one change i commit it. Then, after commiting 3 or 4 changes i push it all.

What i would like to do is to push just one of those revisions that i have locally. can i do that? How?

Thanks

解决方案

Try working in a local 'work' branch. This has advantages such as you can switch to a different branch if you get called to work on say, a bug.

When you're ready to push: git checkout master, git pull, git merge work, git push, will be your normal flow.

However, you can cherry-pick commits from your work branch to the master, that way only those commits will be pushed.

git checkout master
git cherry-pick <id of commit you want>
git push

You could likely do this even now.

git checkout -b work
git log (and look for the IDs of the commits you want)
git checkout master
git reset --hard HEAD~3 (remove last 3 commits from master)
git cherry-pick <ID of commit you want>
git push

这篇关于向GIT存储库推送一个修订版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆