Simon Kraus
Simon Kraus

Reputation: 736

How can i reset anything after commit?

I need to commit a folder, then reset anything else to the remote state and push the commit.

If I would do

git commit
git reset --hard
git push

then the git reset --hard would destroy the commit, right? how can I achieve it?

Upvotes: 1

Views: 44

Answers (1)

Chris Maes
Chris Maes

Reputation: 37832

after performing a commit, you can safely do

git push

This will only push the commits that you made. Any unstaged or untracked changes will remain locally, you don't need to remove them.

Suppose you really want to remove them for another reason; to remove all the unstaged changes (warning: those changes will be lost!) you can do:

git checkout -- :/

if you have any untracked changes; and you don't want them to show up, you can either

  • remove those files
  • put them in the .gitignore file.

Upvotes: 1

Related Questions