Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 10

Discarding changes in working directory not working

Hi,

 

I have the following git status:

 

>git status
On branch BR1
Your branch is up-to-date with 'origin/BR1'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: app/Branch.php

 

Following the above advice provided by git I tried to discard changes in app/Branch.php, so I did:

>git checkout -- app/Branch.php

 

Nothing appeared on the screen, so I assumed, everyting went ok. However, it does not affect the repo:

>git status
On branch BR1
Your branch is up-to-date with 'origin/BR1'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: app/Branch.php

 

What do I do wrong?

9 Replies
Commander Lvl 2
Message 2 of 10

Re: Discarding changes in working directory not working

You can find the solution here , try to run this:

$git checkout app/Branch.php

 

Copilot Lvl 2
Message 3 of 10

Re: Discarding changes in working directory not working

Thanks, sure I tried it, but with no effect:

 

c:\xampp\htdocs\ek>git checkout app/Branch.php

c:\xampp\htdocs\ek>git status
On branch master
Your branch is behind 'origin/master' by 66 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: app/Branch.php

 

 

Copilot Lvl 2
Message 4 of 10

Re: Discarding changes in working directory not working

After updating git to newest version it does not report any changes not staged for commit. Strange, since I just updated git, I didn't checkout the files.

 

c:\xampp\htdocs\ek>git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env_kopia

Commander Lvl 2
Message 5 of 10

Re: Discarding changes in working directory not working

I recommend you to use Gitkraken it's very user frendly and powerfull.

Ground Controller Lvl 1
Message 6 of 10

Re: Discarding changes in working directory not working

This has been most of my experience with git.  Checkout does absolutely nothing and I'm beginning to consider conspiracy.

 

Checkout does nothing

It does nothing

 

And it's all over the internet that it does nothing and everyone avoids the question.

I cannot download previous versions, making github just an upload site.

Commander Lvl 3
Message 7 of 10

Re: Discarding changes in working directory not working

No, @Carocrazy132, I don't think it is a conspiracy :)

 

If you're having trouble with the command line, I do indeed suggest using a visual tool like GitKraken or built-in ones at Visual Studio or Atom like @Wabri mentioned.

 

Anyway, if you want to use the command line, all info you need should be in here: https://stackoverflow.com/a/14075772


- Mark
Copilot Lvl 2
Message 8 of 10

Re: Discarding changes in working directory not working

I have the same issue using GitKraken.

Commander Lvl 2
Message 9 of 10

Re: Discarding changes in working directory not working

Hi @andresams,

 

Could you please psot some sort of log of the errors?

 

Thanks

 

-Gabriele-

 

Mark helpfull posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great contents!

Copilot Lvl 2
Message 10 of 10

Re: Discarding changes in working directory not working

GitKraken does not see this situation as an error, so there is no log. The file just keeps appearing again and again.

 

I am a GitKraken pro user so I will ask them directly for support.