1

I'm very new to git and I'm still confused about how it works. So I forgot to do pull the repo (of the project that my group is working on) daily, and then made changes to the older version of the repo. There has been some structural changes to the project over the few days that I forgot to pull the repo.

If I push my work now, would I bring back the whole project back to the older version? Someone advised me to use git stash while Im pulling the new repo, and I don't know how to integrate only my new work to the newer version of the project.

I would really appreciate any explanation/advice. Thank you

3
  • 1
    What does git status show you? Also, did you commit your changes that you made? Commented Sep 9, 2014 at 2:39
  • If you made commits how many did you make? The situation you describe sounds easy to resolve but I need more info to tell you what to do. Commented Sep 9, 2014 at 2:40
  • If your query was resolved, don't forget to accept an answer... Commented Sep 18, 2014 at 11:34

2 Answers 2

1

If you haven't made any commits, then:

  • stash your changes using git stash
  • pull in changes of other users using git pull
  • pop your local changes back on to the updated repo using git stash pop
  • resolve conflicts if you get any conflicts
  • add files that you've changed using git add file1 file2
  • commit your changes using git commit -m "msg"
  • push back your changes using git push

PS: If you are worried about breaking anything, make a backup of your codebase locally (just create a copy of the project at discreet location)

Sign up to request clarification or add additional context in comments.

Comments

1

This is a really great question. Suprisingly, when I was still in university- so many students including my self had a tough time understanding github's work flow. It seemed that the kids who knew what git commands to do were memorizing some trick I had no idea about.

There's a couple of really great references to help you get started and navigate your way through git's workflow. The best post out there is by one of the founder's of Github. He posted this article, "Github Flow". It's a must read and will really clarify alot of the inner workings of your workflow in relation to github and will also suggest best practices. The second one is called "A successful Git branching model". This one also outlines the fundamentals of feature and branch management. I don't want to specifically reccommend doing a git stash or a git pull or a git push. Because I don't know exactly what the status of your branches are right now. I also belive in the Etymology, "if you give a man a fish he is hungry again in an hour. If you teach him to catch a fish you do him a good turn" haha.

I promise you those two articles will really help you solidify your understanding of git's distributed revision control and source code management system.

Please let me know if you have any questions!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.