Git: How can I go back to my MASTER without committing?

My branch is master

tangled. I should have installed branches before, but I just figured out why they are needed!

So, I have a bunch of changes to master

that I don't want to commit yet, but I have some patching stuff on a new branch that I want to commit.

How can I put all this master

aside and pull a small fix out of the branch?

Basically, I'm not ready to push any stuff in the screenshot yet:

Overview of Git Main Branch

+3


source to share


3 answers


git stash

DESCRIPTION
       Use git stash when you want to record the current state of the working
       directory and the index, but want to go back to a clean working
       directory. The command saves your local modifications away and reverts
       the working directory to match the HEAD commit.

      

you also can

git stash list

      



will show all the stamps you have created and

git stash clear

      

if you just want to discard the hidden changes.

+6


source


As of Git 2.5 (Jul 2015), you can use git worktree :

git worktree add -b patch-1 ../patch-1

      



This is essentially just a branch creation, but it puts the new branch in a new folder next to the parent repo. This is nice because you can branch this without even committing, then go back to master with a clean working directory.

+1


source


I may be misunderstanding, but you could not just bring your master back to a less creepy time and then commit your fixes. If I understand you, this is what I will do.

-1


source







All Articles