+4 votes
1 view
in DevOps and Agile by (30k points)
edited by

How do I discard changes in my working copy that are not in the index?

1 Answer

+5 votes
by (51.2k points)
edited by

You can discard unstaged changes in git using the following commands

For added or modified file that is not staged we use the following

For all unstaged files in the working directory

$git checkout -- .(. For all files)

$ git checkout -- <path to that file>(for a specific file to be discarded)

or you can use

 $git stash 

Then if you need to discard the untracked you can use 

$git clean -i

here -i mean interactive mode then it will open like this 

image

There are options for you and you can select your option, clean will be used to discard the untracked file in git. 

For better understanding about these commands go through the following crash course on git that will help you to understand git well

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...