0

I've done this before but it is not working for me now. We have a few branches

  • develop
  • dev_user1
  • dev_user2
  • dev_user3
  • master

The three of us developing the project merge our work into develop and then after testing on to master. Just normal stuff. My branch user2 was behind a few commits and I needed the changes so I merged and now my branch on github is up-to-date. However I have a lot of code on my local machine that has changed but not committed. Rather that pull all the files form dev_user2 I just want to pull a couple of files and replace or update the local files.

In the past I used git checkout PATH but that does not seem to work now.

Any suggestions?

dmgd
  • 425
  • 4
  • 15
  • possible duplicate of [How to checkout only one file from git repository?](http://stackoverflow.com/questions/2466735/how-to-checkout-only-one-file-from-git-repository) – joran Aug 27 '15 at 21:43

4 Answers4

1

Alternativly you can download a file from github with

wget https://raw.githubusercontent.com/< username>/< project>/< branch>/< file>
joran
  • 2,815
  • 16
  • 18
0

git reset --hard. This will revert to the point before you merged your files.

0

You can do a hard reset (losing all local changes) with git reset --hard.

If you want to keep the local changes without commiting, do:

git stash
git pull
git stash apply

The last line will potentially lead to conflicts in files, which you then have to resolve.

Netzdoktor
  • 526
  • 4
  • 15
0

What I get from your question is you have done a pull, and now you want to revert certain files to your last commit state by doing "git checkout PATH", but when you do so, you remain in the post-pull state -- nothing has changed.

If that's indeed what you are describing, this is likely what's happening: When you do "git checkout PATH", git checkouts PATH from HEAD, which is the most recent commit in your active branch. Most likely this is revision of PATH that you're already working on, so it seems like nothing is happening.

If you do git log PATH, you'll see the revision history of path, and you can find the last commit you made, which hopefully contains a version of PATH you want to access to. Then you can do:

git checkout HASH PATH

and now PATH will reflect that commit. If it's not what you want, "git checkout PATH" will get you back to where you are now. You can also get PATH from another branch if that's what your trying to do.

Spacemoose
  • 3,856
  • 1
  • 27
  • 48