0

Say I have a repo called repo1

Within this repo i have 5 revisions, with A being the most recent

A B C D E

Say I have a workspace with files at revision B but for some reason git thinks I'm at revision C.

I am interested in pulling down the git metadata so that my workspace is in the correct state(e.g git thinks i have revision B) but I do not want the files

My first idea was to run :

1) git pull -n

2) git reset --mixed B

However , this would fail due to merge conflicts

My second idea is to run :

1) git fetch -n

2) git reset --mixed FETCH_HEAD

3) git reset --mixed revision B

Is this the best solution ?

Thanks for your help.

Mark Fisher
  • 965
  • 1
  • 11
  • 30
user3009900
  • 61
  • 1
  • 3
  • Note that `FETCH_HEAD` is special in that names of *all* the refs that got updated during fetching are written here. Hence passing it to `git reset` in a general case has little sense. – kostix Dec 17 '13 at 12:46

1 Answers1

0

--mixed is the default action for reset, so you can omit that flag.

If you know your files are at revision B and revision B is already present in the repo, you can just reset direct to that SHA, no fetching needed:

git reset <sha>

If the commit isn't in the repo (e.g. you manually copied the files over), then you can fetch and reset to it:

git fetch <repo-with-b>
git reset <sha>

That will leave your actual files as they are, but tell Git that your repository is on the revision specified by <sha>.

Amber
  • 507,862
  • 82
  • 626
  • 550