Reputation: 5999
I download the last version from the server with
git fetch
as far as I understood now the repository is updated.
I have two questions :
Now I worked on file that was changed from the server and I want to do the merge ? when Do I need to do the merge ? Do I need to do it after the git fetech or when I do the add files ? could you please exaplain me what should be the statmentes for the merge process ?
If I want to update my workign directory and I don't have any merge How I can do it ? I tried to do it with :
git checkout -f "mybranch"
git rebase
git checkout "mybranch"
is it ok ? Do I have different way ?
Upvotes: 0
Views: 82
Reputation: 120258
I don't merge in this case. If I have outstanding changes, I do
git stash
git checkout master #if I'm not on master
git fetch origin
git rebase origin/master
git checkout whateverbranh #if I was not on master
git rebase master #if I was not on master
git stash pop
I think a lot of people don't do this; I like it because it keeps my history line linear.
You can't always avoid a merge. In this case, if files have changed on the server, and my commits have changed those same files, I have to resolve the conflicts during the rebase.
Upvotes: 2
Reputation: 132011
The most common workflow is
git pull
# do something useful
git commit
git push
pull
is just fetch
and merge
(means: merging remoteName/branchName
into branchName
) and in most cases sufficient.
Upvotes: 1