This article will show you the QA perspective of managing local git repository. You’ll also find out how to rebase and clean your branches. Buckle up!
Managing your local git repository from a QA perspective
1- Rebasing your branches
Basically, rebasing means updating the branch with the latest code from the master branch. This way, you’ll ensure you’re not testing outdated code.
Rebasing is usually done when you encounter messages like this one: “The source branch is 28 commits behind the target branch”.
It’s necessary because sometimes the code from the master branch has too many changes, and there might be new bugs that you won’t find when testing an outdated branch.
You must open your terminal and enter the following commands to do this. Say, for example, you want to rebase branch XX-1234:
git checkout master git fetch -p origin git checkout XX-1234 git merge origin/master git push origin XX-1234
btw, -p is short for prune. After fetching, it removes any remote-tracking branches which no longer exist on the remote.
After fetching, remove any remote-tracking branches which no longer exist on the remote.
This set of commands will update your local master branch, merge the code from the master branch to your local XX-1234 branch, then push the changes to the remote repository.
2- Cleaning your local branches
Sometimes, your local repository might get too crowded with local branches and use your available disk space if you’re not careful.
To prevent it from happening, you should regularly delete your local branches. To do this, you must open your terminal, navigate to your local repository, and enter this command:
git branch | grep -v "master" | xargs git branch -D
It will delete all your local branches except the master and current branches.
To delete only one branch from the local repository, use this command:
git branch -d branch_name
If you need more details about the QA perspective of managing local git repository, meet us here: