1

I've been Googling this but don't understand other's answers as I am new to git/Github.

I made some changes to a few files on a large project and pushed to GitHub. I then must have updated and pulled an older version and so lost all my changes.

I can still see my changes/commits on GitHub. How do I grab these and 'merge'(?) them back onto my local directories?

EDIT:

OK this is even weirder. These files seem to appear and dissappear on my local when I change branches. Is there anyway to have the modified files from all branches available at the same time?

MeltingDog
  • 14,310
  • 43
  • 165
  • 295
  • 1
    As a tip, you should search before asking. Look here http://stackoverflow.com/questions/3380805/checkout-old-commit-and-make-it-a-new-commit and here http://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo not only read the green answers look what fits your needs – sascha10000 Oct 10 '16 at 00:14
  • @sascha10000 I did search, but as I said, the answers were beyond me. I'm aware I'll probably get downvotes, but I need a little more help trying to understand this. – MeltingDog Oct 10 '16 at 00:17
  • 2
    Make a new Github Repo and experiment around if you are not sure what will happen, maybe this may help you. Take this link, there is a quite accurate description. I don't know what I could tell you more, because everything is explained there. Otherwise if you are unsure take a look into the git man. http://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit the first answer has about 5k upvotes and is quite clear. – sascha10000 Oct 10 '16 at 00:22
  • This is a more general tutorial about git http://juristr.com/blog/2013/04/git-explained/. I didn't recognize that you are new to it. I honestly recommend you to get the concept. It's quite a simple approach. Than you may not have any problems to understand most of the commands. – sascha10000 Oct 10 '16 at 00:30

3 Answers3

0

You probably should get a merge tool to help you resolve git conflicts, and make it easy to manage your repository.

Check this question about git merging

Community
  • 1
  • 1
Canilho
  • 944
  • 5
  • 11
0

First of all, the beauty of git/github is that you never lose anything.

  1. Use git log for viewing your commit history
  2. Use git revert to jump back to the commit that contains the changes that you want to get to.
  3. Take time to read about the basics of git. Here's a great tutorial
willyhakim
  • 327
  • 4
  • 11
0

I found the problem was that when I switched branches there was an automated script that would update and merge that branch with files form the production server.

This seems fine, but since stuff I'd made on other branches wasnt in the production server or my current branch's repo everytime I would switch branches I would lose files from other branches.

Apparently the only way to get around this is to copy paste files from one branch to another or hold off work until it's commit to production. Not the way I would have thought, but there you go.

MeltingDog
  • 14,310
  • 43
  • 165
  • 295