I'm clearly using Git the wrong way, so I'd like someone to tell me what's the actual way of using it.
Basically, me and a co-worker are working on the same project. We pull
ed from the central repository and each one of us start working on different features.
At some point, we both have to modify the same file, so the conflict comes when one of use finish and push
it to the central repository, the other needs to pull
before push
.
Here the issue is, whenever my co-worker push
, I need to pull
and merge files, this end up breaking the whole code. What is the right git event flow in this case?
As you Say when "change made on same file". Git have One Special Command like git Stash. When both of you working on same file and you need to pull the changes from Central repository.
You Can save your current state of Edited files temporarily by:
git stash
You’re back to your original working state.
Then Pull your coworker changes from central repository by
git pull.
Then its merged without conflicting.
git stash list
you can see the list of created stashes with unique id.
Now you can apply Stash by
git stash apply stash@{1}.
So your Stashed Changes are apply to the updated repository. You can continue to work from this Point.