Mathew Kurian
Mathew Kurian

Reputation: 6039

How to sync to the last version without commiting existing changes?

Before I start, I would like to say I am new to git.

Say I have the given scenario:

  1. Forked a repo
  2. Cloned to my desktop via (Github Windows)
  3. Made some changes that I regret (but I added some new files)
  4. I want to get the latest files in the repo and override ONLY the files that already exists in the repo. New files should NOT be deleted.

How do I get step 4 done?

Upvotes: 1

Views: 37

Answers (1)

Jiri Kremser
Jiri Kremser

Reputation: 12837

  1. git stash - save your local changes aside
  2. git pull - pull the latest changes
  3. git stash pop - apply your local changes from the stack

if you wan't to revert any of your local changes selectively, you can invoke git checkout $file

Upvotes: 1

Related Questions