Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I push a specific commit to a remote, and not previous commits?

Tags:

git

commit

push

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit.

Is that possible?

like image 273
Robert23 Avatar asked Jul 12 '10 16:07

Robert23


People also ask

How do I push only a specific commit in Intellij?

Do one of the following: To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.

How do I push a previous commit?

Summary. If you want to test the previous commit just do git checkout <test commit hash> ; then you can test that last working version of your project. If you want to revert the last commit just do git revert <unwanted commit hash> ; then you can push this new commit, which undid your previous commit.

How do I commit a branch to a remote?

Push a new Git branch to a remote repoClone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.


1 Answers

To push up through a given commit, you can write:

git push <remotename> <commit SHA>:<remotebranchname> 

provided <remotebranchname> already exists on the remote. (If it doesn't, you can use git push <remotename> <commit SHA>:refs/heads/<remotebranchname> to autocreate it.)

If you want to push a commit without pushing previous commits, you should first use git rebase -i to re-order the commits.

like image 161
Geoff Reedy Avatar answered Sep 28 '22 05:09

Geoff Reedy