Sourcetree - undo unpushed commits
up vote
174
down vote
favorite
I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.
Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.
I could also delete my local repository and pull it again without my local commit, but maybe there's another way?
atlassian-sourcetree datasourcecontrol
add a comment |
up vote
174
down vote
favorite
I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.
Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.
I could also delete my local repository and pull it again without my local commit, but maybe there's another way?
atlassian-sourcetree datasourcecontrol
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41
add a comment |
up vote
174
down vote
favorite
up vote
174
down vote
favorite
I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.
Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.
I could also delete my local repository and pull it again without my local commit, but maybe there's another way?
atlassian-sourcetree datasourcecontrol
I am using Sourcetree for Windows for a git-repository and would like to undo an unpushed commit.
Is that possible? If I do "revert commit", it creates a second commit which reverts the first commit, but I don't want the first commit to appear at all in my source control.
I could also delete my local repository and pull it again without my local commit, but maybe there's another way?
atlassian-sourcetree datasourcecontrol
atlassian-sourcetree datasourcecontrol
edited Nov 19 at 23:03
shim
3,77764477
3,77764477
asked May 26 '14 at 7:56
deimos1988
1,98173051
1,98173051
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41
add a comment |
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41
add a comment |
3 Answers
3
active
oldest
votes
up vote
292
down vote
- Right click on the commit you like to reset to (not the one you like to delete!)
- Select "Reset master to this commit"
- Select "Soft" reset.
A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
|
show 2 more comments
up vote
32
down vote
If you select the log entry to which you want to revert to then you can click on "Reset to this commit". Only use this option if you didn't push the reverse commit changes. If you're worried about losing the changes then you can use the soft mode which will leave a set of uncommitted changes (what you just changed). Using the mixed resets the working copy but keeps those changes, and a hard will just get rid of the changes entirely. Here's some screenshots:
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
add a comment |
up vote
0
down vote
If You are on another branch, You need first "check to this commit" for commit you want to delete, and only then "reset current branch to this commit" choosing previous wright commit, will work.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
292
down vote
- Right click on the commit you like to reset to (not the one you like to delete!)
- Select "Reset master to this commit"
- Select "Soft" reset.
A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
|
show 2 more comments
up vote
292
down vote
- Right click on the commit you like to reset to (not the one you like to delete!)
- Select "Reset master to this commit"
- Select "Soft" reset.
A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
|
show 2 more comments
up vote
292
down vote
up vote
292
down vote
- Right click on the commit you like to reset to (not the one you like to delete!)
- Select "Reset master to this commit"
- Select "Soft" reset.
A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.
- Right click on the commit you like to reset to (not the one you like to delete!)
- Select "Reset master to this commit"
- Select "Soft" reset.
A soft reset will keep your local changes.
Source: https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
Edit
About git revert
: This command creates a new commit which will undo other commits. E.g. if you have a commit which adds a new file, git revert
could be used to make a commit which will delete the new file.
About applying a soft reset: Assume you have the commits A
to E
(A---B---C---D---E
) and you like to delete the last commit (E
). Then you can do a soft reset to commit D
. With a soft reset commit E
will be deleted from git but the local changes will be kept. There are more examples in the git reset documentation.
edited Jan 11 '16 at 12:27
answered Oct 15 '14 at 9:53
nightlyop
4,98131734
4,98131734
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
|
show 2 more comments
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
31
31
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
Or if you're working on a branch - "Reset current branch to this commit"
– Tom Auger
Aug 12 '15 at 13:26
4
4
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I so much don't understand these UI explanations... Reset current branch to this commit so much doesn't sound like it will delete the commit. And it ended up doing what you would expect more. It reset my working copy to the commit, instead of deleting it.
– MrFox
Nov 24 '15 at 13:32
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
I agree with @MrFox. After I did this the commit I don't want is still shown in the tree.
– Timmmm
Jan 11 '16 at 11:09
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
@Timmmm: Does the new explanation help?
– nightlyop
Jan 11 '16 at 12:29
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
Actually I realised that I had already pushed my commit to github. I found an article that explains how to "rewrite history" but it seems like it is more trouble than it is worth!
– Timmmm
Jan 11 '16 at 15:40
|
show 2 more comments
up vote
32
down vote
If you select the log entry to which you want to revert to then you can click on "Reset to this commit". Only use this option if you didn't push the reverse commit changes. If you're worried about losing the changes then you can use the soft mode which will leave a set of uncommitted changes (what you just changed). Using the mixed resets the working copy but keeps those changes, and a hard will just get rid of the changes entirely. Here's some screenshots:
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
add a comment |
up vote
32
down vote
If you select the log entry to which you want to revert to then you can click on "Reset to this commit". Only use this option if you didn't push the reverse commit changes. If you're worried about losing the changes then you can use the soft mode which will leave a set of uncommitted changes (what you just changed). Using the mixed resets the working copy but keeps those changes, and a hard will just get rid of the changes entirely. Here's some screenshots:
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
add a comment |
up vote
32
down vote
up vote
32
down vote
If you select the log entry to which you want to revert to then you can click on "Reset to this commit". Only use this option if you didn't push the reverse commit changes. If you're worried about losing the changes then you can use the soft mode which will leave a set of uncommitted changes (what you just changed). Using the mixed resets the working copy but keeps those changes, and a hard will just get rid of the changes entirely. Here's some screenshots:
If you select the log entry to which you want to revert to then you can click on "Reset to this commit". Only use this option if you didn't push the reverse commit changes. If you're worried about losing the changes then you can use the soft mode which will leave a set of uncommitted changes (what you just changed). Using the mixed resets the working copy but keeps those changes, and a hard will just get rid of the changes entirely. Here's some screenshots:
edited Apr 14 '16 at 9:42
answered Apr 14 '16 at 9:37
Muhammad Awais
1,80512320
1,80512320
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
add a comment |
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
3
3
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
If you still see a icon showing a Push is available from your previous commit (Which you just wiped out), pull and Sourcetree seems to update the UI.
– ChristoKiwi
Nov 11 '16 at 4:56
add a comment |
up vote
0
down vote
If You are on another branch, You need first "check to this commit" for commit you want to delete, and only then "reset current branch to this commit" choosing previous wright commit, will work.
add a comment |
up vote
0
down vote
If You are on another branch, You need first "check to this commit" for commit you want to delete, and only then "reset current branch to this commit" choosing previous wright commit, will work.
add a comment |
up vote
0
down vote
up vote
0
down vote
If You are on another branch, You need first "check to this commit" for commit you want to delete, and only then "reset current branch to this commit" choosing previous wright commit, will work.
If You are on another branch, You need first "check to this commit" for commit you want to delete, and only then "reset current branch to this commit" choosing previous wright commit, will work.
answered Mar 29 '17 at 6:59
pomaranga
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23865335%2fsourcetree-undo-unpushed-commits%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I have written a detailed article with screenshots. Sharing in hope that it would help: attosol.com/undo-in-git-using-sourcetree
– Rahul Soni
Jan 22 at 5:41