Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

git checkout reports error even though working tree is clean Edited

I am no my local my-feature branch

git status reports nothing to commit, working tree clean

I want to switch to develop branch and do git fetch and git merge there (I prefer it over git pull)

However, doing so produces error below

Here I first check status and it shows that all is clean

mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean

Next I try to checkout my develop branch which is an existing local branch

On branch my-feature
nothing to commit, working tree clean
mymbp:MyProj username$ git checkout develop
error: Your local changes to the following files would be overwritten by checkout:
    MyProj.sln
Please commit your changes or stash them before you switch branches.
Aborting

It complains that myProj.sln has been changed even though git status says nothing has changed.

Issuing git status again, confirms that nothing has changed

mymbp:MyProj username$ git status
On branch my-feature
nothing to commit, working tree clean

1 answer

0 votes
BillyP Community Leader Nov 09, 2018

Hi @dbnex

If you change your file in your editor and save it, it will be recognized as a change.  It isn't until the file is committed will git allow you to move on to a different branch. 

Option 1

Discard any changes in current branch.  Via the command below.  

git checkout -- . 

Next, switch to new branch and continue working

git checkout -b new-branch

Option 2

https://git-scm.com/docs/git-stash 

 

I prefer Option 1 as then I don't have a loose thing to come back and deal with later.  Extreme Coding principles being what they are :)

 

Hope this helps!

@BillyP Thanks Billy but I am not sure you understand my question.  

Option 2 makes no sense since git status, git diff, stash show that there is nothing changed, working tree is clean.  But git checkout sees this one file as changed, this is all in question above.

Option 1 makes no sense to me since all I can find about git checkout -- seem to be related to file and directory named same way, I dont have that in my case.

I posted this question and added some more updates here to clarify https://stackoverflow.com/questions/53214095/git-checkout-errors-even-though-git-status-reports-that-working-tree-is-clean

Thanks for your suggestions, 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in DevOps

Step up your DevOps game webinar Q&A series - Questions answered!

  On October 21st, 2020 we hosted a webinar titled,   Step Up You DevOps Game with 4 Key Integrations for Jira and Bitbucket. We had a great showing and high engagement, but that meant th...

106 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you