Reputation: 2045
We have just started with git few days ago and we decided that all of our team will push to master branch directly from local. So, each of us will be responsible that our commit is runnable.
So far, we have met a problem, that is there is plenty of commit message "Merge remote-tracking branch 'refs/remotes/origin/master'" in history
. This occurs when we git fetch and git merge the latest, and push commit to master.
It seems not a good thing for us. Is there any ways to overcome it?
We have research and think that it can be overcome by using rebase
(some say should not use if not knowing much about git). But not sure how it is to be done exactly.
Hope that someone in stackoverflow can help us out. Particularly on:
1) What is the actual step to be done when fetching and merging latest update from server before push.
2) Should we remain the commit with message "Merge remote-tracking branch 'refs/remotes/origin/master'" in history
for subsequence push or find a way to not have it in commit history for future push?
Upvotes: 1
Views: 7095
Reputation: 3801
Your team should be branching off of master, and merging their branches to master with the --ff-only
flag. They'll use rebase to make sure they're always working off of the most recent version of master.
e.g.
git checkout master
git pull # now master is up to date
git checkout -b my-feature
# work work work
git add .
git commit -m "I did some work"
# other people were making changes at the same time,
# and some new features got added to master.
git checkout master
git pull # now master is up to date again
git checkout my-feature
git rebase master
# ^^^^^^^^^^^^^^^ this makes it seem like "I did some work"
# happened on the most recent version of master
# ready to merge my work onto master
git checkout master
git merge my-feature --ff-only # ff-only prevents the merge commit that you're trying to avoid
git push
# now everyone on the team can see my changes
Upvotes: 1