FluxEngine
FluxEngine

Reputation: 13310

Removing changes from a file - GitHub/Git

I have cloned a project newProject and created a branch new_branch.

I made a few changes to new branch but after reviewing everything, I have decided not to use those changes, I have checked out the master branch, but when I use git status it still shows the modified files.

I have gone back and deleted new_branch but the modified changes are still there.

How do I delete the modifications (not the files themselves)?

Upvotes: 1

Views: 1682

Answers (2)

pktangyue
pktangyue

Reputation: 8544

using git reset --hard will remove changes of tracked files.

using git clean -df will remove new added untracked files.

Upvotes: 4

Kevin Bowersox
Kevin Bowersox

Reputation: 94499

Execute the following command, which will remove all changes and newly created files

 git clean -df

Another option, if you wanted to save the changes for possible use later, but still remove them from the branch you could execute:

git stash

Then when you want to put these changes back in execute:

git stash apply

Upvotes: 0

Related Questions