I’ve started working on a project with another developer and have only just realised how limited my GIT knowledge is. Here’s the deal:
- I’ve been making changes during this week, and want to push them to master
- My colleague made changes to the same project yesterday and pushed them last night
How am I supposed to proceed?
If I try and push my changes, I’ll get error because my code is out-of-date.
So, I’m told I should STASH my changes, then PULL his changes into my working directory, then STASH APPLY my changes back.
But when I do that, I get conflict errors because we have BOTH changed the project file.
If I then look in the files to see the conflicts, I find that they’re not “labelled” like a normal conflict, so I can’t fix the problem! I can’t even compare my two versions, because the conflicted versions are the old ones.
Any help, very much appreciated.
git fetchthe changes from the remote branchgit rebaseyour commits on top of the commit history established in the remote branch you just fetchedgit pushyour history which now contains your latest series of commits. Your friend can follow this same procedure to get your commits into his local history as well.Reading the official documentation is always important. Also, I’ve found this visual cheatsheet to be helpful as well.