You’re at the right place if you’re looking forward to Refresh and Relearn Git Commands in the fastest possible way.
📌 Got a better free video course than the one above? Share the link in the comments for it to be considered to replace the video above!
Why is mastering git commands important for automation testers? Mastering Git commands is crucial for automation testers. It provides essential version control capabilities for tracking changes. It also helps in managing branches and collaborating effectively with developers.
Automation testers can use Git’s branching and merging features to isolate test scripts for different features. This approach ensures a streamlined development process. It also manages risks effectively. Proficiency in Git enables efficient collaboration through code reviews, facilitates continuous integration and deployment, and offers traceability through commit histories.
Additionally, it allows testers to maintain and update automation scripts effortlessly. This adaptation keeps pace with changes in the application. It contributes to the overall stability and reliability of the test automation framework.
Git Commands 101: Key Commands Every Tester Needs to Know Command Description git init
Initialize a new Git repository git config --global user.name "Your Name"
Set your username globally for Git git config --global user.email "your.email@example.com"
Set your email globally for Git git clone <repository_url>
Clone a repository from a remote server git branch <branch_name>
Create a new branch git checkout <branch_name>
Switch to an existing branch git checkout -b <new_branch_name>
Create and switch to a new branch git add <file_name>
Add changes to the staging area git add .
Add all changes to the staging area git commit -m "Your commit message"
Commit changes with a descriptive message git fetch
Fetch changes from the remote repository git pull origin <branch_name>
Pull changes from a remote branch git push origin <branch_name>
Push changes to a remote branch git push -f origin <branch_name>
Force push changes to a remote branch (caution) git merge <other_branch>
Merge changes from another branch git rebase <base_branch>
Rebase changes onto another branch git status
Check the status of your repository git log
View commit history
Various Git commands grouped by their functionalities Configuring Git Command Description git init
Initialize a new Git repository git config --global user.name "Your Name"
Set your username globally for Git git config --global user.email "your.email@example.com"
Set your email globally for Git
Creating and Cloning Repositories Command Description git clone <repository_url>
Clone a repository from a remote server git clone --branch <branch_name> <repository_url>
Clone a specific branch from a repository git branch <branch_name>
Create a new branch git checkout <branch_name>
Switch to an existing branch git checkout -b <new_branch_name>
Create and switch to a new branch
Staging and Committing Changes Command Description git add <file_name>
Add changes to the staging area git add .
Add all changes to the staging area git commit -m "Your commit message"
Commit changes with a descriptive message git commit --amend
Amend the last commit with new changes git reset HEAD <file_name>
Unstage changes from the staging area git restore --source=HEAD --staged --worktree <file_name>
Unstage changes and discard local changes git restore --source=HEAD --worktree <file_name>
Discard local changes without unstaging git revert <commit_hash>
Create a new commit that undoes a previous commit
Fetching and Pulling Changes Command Description git fetch
Fetch changes from the remote repository git pull origin <branch_name>
Pull changes from a remote branch
Pushing Changes Command Description git push origin <branch_name>
Push changes to a remote branch git push -f origin <branch_name>
Force push changes to a remote branch (caution)
Merging and Rebasing Command Description git merge <other_branch>
Merge changes from another branch git rebase <base_branch>
Rebase changes onto another branch git rebase -i HEAD~<number_of_commits>
Interactive rebase for squashing commits
Branch Management Command Description git branch
List all branches git branch -d <branch_name>
Delete a branch (merged) git branch -D <branch_name>
Delete a branch (force delete, caution) git branch -m <new_branch_name>
Rename the current branch git branch -a
List all branches, including remote branches
Checking Repository Status Command Description git status
Check the status of your repository git log
View commit history git log --oneline --graph --all
Compact log with graphical representation git diff
Show changes between working directory and staging git diff --staged
Show changes between staging and last commit git show <commit_hash>
Show details of a specific commit
Remote Repository Management Command Description git remote
List remote repositories git remote add <remote_name> <repository_url>
Add a new remote repository git remote -v
List remote repositories with URLs git remote show <remote_name>
Show information about a remote repository git remote remove <remote_name>
Remove a remote repository
Git Tagging Command Description git tag
List all tags git tag <tag_name>
Create a new tag git tag -a <tag_name> -m "Your tag message"
Create an annotated tag with a message git tag -d <tag_name>
Delete a tag git push origin <tag_name>
Push tags to a remote repository git push origin --tags
Push all tags to a remote repository
Miscellaneous Command Description git clean -n
Preview untracked files to be deleted git clean -f
Delete untracked files git stash
Temporarily save changes (for later use) git stash apply
Apply stashed changes back to the working directory git cherry-pick <commit_hash>
Apply changes from a specific commit git blame <file_name>
Show who changed each line in a file git grep "search_term"
Search for a term in your codebase
This list covers a wide range of Git commands for different use cases. Adjust commands based on your specific needs and workflow.