Article based on: https://www.atlassian.com/git/tutorials/merging-vs-rebasing/the-golden-rule-of-rebasing
Gitflow was in implemented by my team 6 months ago, but I’m not here to talk about it. I like it.
But there is a big problem : History
Git Commit History Problem
Many developers do not have problem with their git repositories, nor the commit history. Merge Commits or Resolved Conflicts Commits isn’t a problem. But in a CI ( Continuous Integration ) workflow, their comments are changelog files.
Example for comments for commits in your repo history :
- Merge pull request #001 from feature
- Resolved Conflicts for Merge
- Fix conflicts
- Merge
Rebase
A month ago, we migrate the workflow for Git Rebase in approved pull request. But this is not a simple migration, in Github has a merge button leads to the dark side, for this we have created a small tutorial.
Step-by-step
Step 1 : Get last Hash in Git
You need the last commit hash before your features, as in the figure below:
git log
Step 2: Rebase within your branch
Execute rebase in your branch for create a unique commit for your feature and solve the conflicts. Use “git log” to verify history change.
git rebase -i HASH
Step 3: Update Master Branch ( For me develop)
You need change local branch and pull wall changes.
git checkout develop
git pull
Step 4: Make rebase from master
Change to feature branch and make rebase command for sync with develop ( or master). Push feature branch for Github close pull request.
git checkout feature
git rebase develop
git push origin -f feature
Step 5: Make rebase within master
You need now make rebase in develop ( or master ) to update git history. Do as the same in step 4 but invert master and feature. This is the last step to close a pull request, in my case, the github detect.(Thanks Github!)
git checkout develop
git rebase feature
git push
Conclusion
In big projects your Git, in my case Github, is the heart of your code and software. 5 minutes tor make the history commit better, it’s nothing. I want to thank the Tech Leader of my team (Christopher Morris), who inspired me to create this post. Yes, he likes a clean git.
If you have a better idea, share with me. Thanks!