Hi
I see a number of answers which are more confusing about this. It is really simple not having merge commits. Do not merge! Do rebase. This is my workflow, there are maybe others.
I assume you “forked” ansible on github and then cloned the forked to your local machine.
So one important thing is to not doing any commits in long term branches of the project. e.g. in ansible this would be devel. You only need to use this branch to sync with so called upstream. So how do we sync with upstream? Add the remote to your git repo.
git remote add upstream git@github.com:ansible/ansible.git
Now, you can sync with it:
git checkout devel
git pull upstream devel
So your devel branch is only there to pull from the latest changes, nothing more. So now, we want to create a new feature:
git checkout -b feature/new
edit
git commit -m “add new feature”
while we worked on that for 3 months… there were likely commits in the upstream project. So you project may be a bit “out of sync” and maybe it can not be merged because of conflicts. So how we do get in sync now? Sync again the devel branch.
git checkout devel
git pull upstream devel
Switch to your feature branch
git checkout feature/new
git rebase devel
Now, your changes were put no top (see git log) in line. Now you can create a pull request using your origin.
git push origin feature/new
Leave this branch like it is until your featrue has been merged. maybe you have to add more thing to it.
One important thing to note, rebase does change your history. if your pull request has been merged in, you should not rebase it from devel branch again and push it for another pull request. Removed this branch, when it has been merged.
But as long as it has not merged, you can rebase it from devel branch again. This would be very nice for the Ansible guys to see your changes in line.
After you rebase your feature branch again, you will not be able to do push it again
git push origin master
without -f alias force. As the history has changed (as I wrote before). Be careful with -f as it will overwrite without ask.
Hope this helps.
Regards
René
But as long as it is not merged you can rebase it with devel.