Search code examples
gitbranch

Switching between branches in Git


I’m using Git to keep track of various Python scripts for data evaluation. I have one set of scripts for the standard tasks and a branch of these scripts for one special task. So if I’m just changing little things (like input filenames) in the one branch and want to do something in the other branch I cannot check out the desired branch, since there are uncommitted changes. But I don't want to commit these changes, since the are completely irrelevant.

How can I overcome this little problem?


Solution

  • You need

    git stash
    

    This command allows you to stash your current changes which you won't wish to commit. Once you do this, your working directory is clean and you can now switch between branches using

    git checkout <branch-name>
    

    More on git stash can be found on the official documentation.