Reputation: 381
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
Upvotes: 1
Views: 1575
Reputation: 6112
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!
Upvotes: 1
Reputation: 76847
If you haven't made any commits, then:
git stash
git pull
git stash pop
git add file1 file2
git commit -m "msg"
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)
Upvotes: 1