So, I've been doing some research on git rebasing as I'm the only person working on my branch and I'd like to avoid merge conflicts before the merge request finds them. I've found 2 methods using command line and I'm confused about the commands and if one is safer to use than the other. Then of course there's using merge from develop instead, but at least one of these recommends rebasing everyday.
One step that neither mentions is that if there are changes I've made that I do NOT want to commit that I need to stash them.
One method is from
git Rebase how to use it properly.
and it's steps are:
• go to your feature branch
• git fetch
• git rebase -i origin/develop. (NOTE: i don't fully understand what this command does... Is it pulling the newest from remote develop or just my local?)
• it will open the editor and remove all commits that are NOT yours
• then close the editor
• if there are conflicts, fix it manually, save and commit it
• git rebase — continue
• #important, don’t do any git pull to merge from remote
• git push — force-with-lease (overwrite the remote even there is divergent) (NOTE: this seems dangerous)
the 2nd is from
git Best practices
It's steps are:
# grab the latest stuff from origin/master to update your local master branch
> git checkout master
> git pull origin master
# go back to MYBRANCH and now rebase with the changes in your local master branch
>. git checkout MYBRANCH
> git rebase master
# if you encounter merge conflicts… edit each affected file, then git add that file. Then
> git rebase --continue[list]# commit your updated branch to origin. May require a -ff to force.
>. git push origin MYBRANCH
[/list/
What steps do you prefer to ensure that your branch will merge?