简体   繁体   English

如何无法将本地git commit推送到远程

[英]How can not push local git commit to remote

I just want to commit local branch, and not push to remote. 我只想提交本地分支,而不要推送到远程。 Then I can merge updates from remote branch. 然后,我可以合并来自远程分支的更新。 When push to remote, I can selectively avoid push this specific commit to remote, and others commits can be pushed to remote branch. 推送到远程时,我可以有选择地避免将此特定提交推送到远程,而其他提交可以推送到远程分支。

How to do this with git commands ? 如何用git命令做到这一点?

"I can selectively avoid push this specific commit to remote, and others commits can be pushed to remote branch" -> No, you can't push "later" commits without pushing the "earlier" ones. “我可以有选择地避免将特定的提交推送到远程,而其他提交可以推送到远程分支。”->不,您不能在不推送“较早的”提交的情况下推送“较晚的”提交。 As @Heather says - put changes you don't want to push back to the origin on another local branch. 正如@Heather所说的那样,将更改不想回滚到另一个本地分支上的原点。

You can try this: 您可以尝试以下方法:

Run git rebase -i HEAD~n (n is uptil that commit that you dont want to push) 运行git rebase -i HEAD~n HEAD〜n(n直到您不想推送的提交为止)

It will open a list of commits in your favourite editor. 它将在您喜欢的编辑器中打开提交列表。 Pick the line that has special commit and move it to the end. 选择具有special提交的行并将其移到末尾。

Save and Continue. 保存并继续。

This will effectively bring the commit you dont bant to push to top. 这将有效地将您不愿提交的承诺推到最高。 drop a branch just before this commit, and push to remote. 在此提交之前删除一个分支,然后推送到远程。

Hope this solves your problem! 希望这能解决您的问题!

Happy gitting! 快乐的混蛋!

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

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