git rebase and Refactoring my code, I worked on my goURL repo.
I planned to do three commits with three different refactors.
- extract functions to reuse.
- improve variable names.
- split the util functions to a new file
Extract functions and improving variables go smoothly. However, when I split the util functions, all my code is broken. all my imported library is still on main.go,
I checked all the libraries needed by the new file and deleted the old imports from
main.go. Then, everything works.
The process of refactoring:
git checkout -b refactoring master // refactoring 1 git add . git commit -m "Extract functions to reuse" // refactoring 2 git add . git commit -m "Improve variable names" // refactoring 3 git add . git commit -m "split the util functions to a new file utils.go" // git log to check the commit history git rebase master -i // change commits message. git commit --amend // merging git checkout master git merge refactoring git push origin master
git rebase is a way to clean our commit history. we also use
git rebase to
update our working branch to fetch the latest commit from the remote repo.