Created a branch from a remote branch for a quick fix, but git status shows my modified files that I had in my previous working branch

I was working on a feature (on my local master branch), git status showed me that I have 3 modified files uncommitted. That’s ok. Then I noticed a bug on the live site. I wanted to abandon my current work, and create a quick fix for the bug.

I created a branch from the remote repo’s master:
git checkout -b quickfix origin/master

  • Create Private Repo creates public repository Visual Studio 2015 Git extension
  • How to get git to change the line ending in the working directory?
  • Git Seems to Have Commit From Remote Pull, But Log Does Not Show Commit
  • Sync between laptop and PC for eclipse projects
  • Should a git repo contain all binary & static files needed to deploy?
  • (tortoise) svn: relocate different branches to different repositories (= different URL and UUID)
  • But git status shows that I have 3 modified files. Why is that? I made no update on any files, only created the branch from the remote.

    I just want to have a clean branch from remote/master that I can start working on with the quickfix.

  • Git Checkout Remote Branch
  • GIT bash on Windows: VIM doesn't find Python3
  • Git push to Staging Server
  • Using both local Git and (remote) TFS with Visual Studio 2013
  • Pushing to remote branch
  • Dropbox and git, could it cause conflicts?
  • 2 Solutions collect form web for “Created a branch from a remote branch for a quick fix, but git status shows my modified files that I had in my previous working branch”

    You should stash your changes, so they are stored in a “floating” commit, and then you can apply them back after you work on your bugfix:

    $ git stash save "Working on ... - going to bugfix"
    $ git status --short # should show only untracked files
    $ git checkout bugfix
    # work work work
    $ git add file1
    $ git commit
    $ git push # probably a merge and that
    $ git checkout master
    $ git stash pop # applies the last stash's changes to working copy
    

    Git won’t delete files just because you switched a branch – that’s good, you wouldn’t want to lose them.
    This is what I would do (starting from the branch :

    git add --all
    git stash
    git checkout quickfix
    # do all the work you need to fix the problem and commit 
    git checkout master
    git stash pop # apply stashed work and remove it 
    

    Git stash saves the changes you made and you may reapply them later after you’re done fixing other things (you can apply stashed work to different branches and more than one time if you need to).

    Git Baby is a git and github fan, let's start git clone.