How to discard unstaged changes in Git

+1 vote

Hi Guys,

I have unstaged changes in the Git repository. I want to discard the unstaged changes from the repository. How can I do that?

Dec 22, 2020 in Git & GitHub by akhtar
• 38,170 points
54 views

1 answer to this question.

0 votes

Hi@akhtar,

You can save the unstaged changes in the stash as shown below.

$ git stash save --keep-index --include-untracked

You don't need to include --include-untracked if you don't want to be thorough about it.

After that, you can drop that stash.

$ git stash drop
answered Dec 22, 2020 by MD
• 95,160 points

Related Questions In Git & GitHub

0 votes
1 answer

How to reset the changes in Git?

Hi@MD, Reset command can be used to undo ...READ MORE

answered Nov 20, 2020 in Git & GitHub by akhtar
• 38,170 points
126 views
0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,890 points
904 views
0 votes
1 answer

How to give a file execute mode permissions in Git?

You can easily do this in one ...READ MORE

answered Aug 6, 2018 in Git & GitHub by Sophie may
• 10,550 points
8,080 views
0 votes
1 answer

How to add a remote git repository in Jenkins

Follow these steps: Step 1 Go to Manage ...READ MORE

answered May 23, 2019 in Git & GitHub by Alok
1,865 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,064 views
+2 votes
1 answer
0 votes
1 answer

How to get changes from master branch to a new branch in Git?

Hi@akhtar, You need to check out the branch and ...READ MORE

answered Jan 4 in Git & GitHub by MD
• 95,160 points
83 views
0 votes
1 answer

How to roll back to previous version in Git?

Hi@akhtar, You can roll back your previous version ...READ MORE

answered Apr 29, 2020 in Git & GitHub by MD
• 95,160 points
190 views