0

I accidentally staged, committed and pushed some files I shouldn't have (along with the files I actually wanted to commit) to my remote repo using GitKraken.

I want now to move those unwanted files back to the staging area without losing the changes I made to them.

Woop
  • 61
  • 9

1 Answers1

1

You can reset your branch to any previos commit by right-clicking the commit you want to reset to and choose Reset <branch> to this commit>. You can choose to reset Soft, Mixed or Hard.

reset options

DO NOT RESET HARD IF YOU WANT TO KEEP YOUR CHANGES! A hard reset is the easiest way to loose data in git. Instead, choosing Mixed will reset the branch to the selected commit and keep the changes as unstaged changes; Soft does the same, but the changes will be staged. You can then carefully select the changes you want to commit and create a new commit.

Disclaimer: You should not reset a repository if you already published your commits! If you already pushed your changes and anyone else bases his work on your commits, resetting or rebasing will lead to conflicts, since your new commits and your old commits will be around. In this case, you might want to remove the changes you did not want to commit in a following commit, either by hand or by using git revert.

kowsky
  • 12,647
  • 2
  • 28
  • 41