Git Tips for Testers | Bondar Academy
Course: Git and GitHub Fundamentals
Module: Working with Git and GitHub
Instructor: Artem Bondar
Lesson Summary
This final lesson provides several useful Git tips to enhance your workflow. Below are key scenarios and commands discussed: Scenario 1: Committing to Master Branch Imagine you accidentally commit changes to the master branch instead of your own branch. To revert this: Use the command: git reset origin master to synchronize your local branch with the origin master branch. This will unstaged your changes. Create a new branch with: git checkout -b my-new-branch . Now, you can safely commit your changes on the new branch. Scenario 2: Switching Branches with Uncommitted Changes If you need to switch branches but have uncommitted changes, you cannot do so directly. Instead: Stash your changes using: git stash save "some work in progress" . Switch to the desired branch with: git checkout first-code . To recover your stashed changes, use: git stash list to view stashes, then git stash apply to apply the changes. Deleting Unused Branches After merging branches, you may want to delete local branches: To delete a local branch, use: git branch -d first-code . To clean up remote branches that no longer exist, execute: git fetch --prune . These tips help streamline your Git usage, allowing for better management of branches and changes.