怎么不能将本地git提交到远程

时间:2021-07-14 16:23:30

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命令执行此操作?

2 个解决方案

#1


0  

"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所说 - 放置更改你不想回到另一个本地分支上的原点。

#2


0  

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(n是你不想推送的uptil)

It will open a list of commits in your favourite editor. Pick the line that has special commit and move it to the end.

它将在您喜欢的编辑器中打开一个提交列表。选择具有特殊提交的行并将其移动到最后。

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!

快乐的gitting!

#1


0  

"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所说 - 放置更改你不想回到另一个本地分支上的原点。

#2


0  

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(n是你不想推送的uptil)

It will open a list of commits in your favourite editor. Pick the line that has special commit and move it to the end.

它将在您喜欢的编辑器中打开一个提交列表。选择具有特殊提交的行并将其移动到最后。

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!

快乐的gitting!