This is for keeping your branch up to date and always having a PR / MR with only one commit. It is helpful if you use Oh-My-Zsh.
Squashing Your Branch#
Checkout your branch#
omz> gco $branch_name zsh> git checkout $branch_name
Rebase your branch from master#
$number_of_commits is displayed in GitLab at the top, where it says
Overview: X, Commits: Y, Pipelines: Z, ...
The number you want is Y.
omz> grbi HEAD~5 zsh> git rebase -i HEAD~$number_of_commits
Force push your branch#
omz> ggfl zsh> git push --force-with-lease origin $current_branch
Update From Master#
Time passes, commits get merged to master. You need to update your branch.
Checkout master #
omz> gcm zsh> git checkout master
Pull#
omz> gl zsh> git pull
Checkout branch #
omz> gco $branch_name zsh> git checkout $branch_name
Rebase from master #
omz> grbm zsh> git rebase master
Handle conflicts, test, etc.
Force push#
Force push $current_branch to remote.
omz> ggfl zsh> git push --force-with-lease origin $current_branch
Push to Master#
Checkout master, merge feature branch into master, push master
Checkout master#
omz> gcm zsh> git checkout master
Merge feature branch into master#
omz> gm $feature_branch zsh> git merge $feature_branch
Push master#
omz> ggp zsh> git push origin master
CategoryComputing.SCM.Git