0% found this document useful (0 votes)
18 views

Git commands

Uploaded by

Bhavin Panchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Git commands

Uploaded by

Bhavin Panchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GIT cheatSheet 👍

Git cheat sheet tailored for Software Development Engineer in Test (SDET) perspective.
Git is a widely used version control system that helps you manage and track changes in your
codebase. This cheat sheet covers basic Git commands and concepts that are useful for SDET
tasks:

Basic Commands:

1. Clone a Repository:

git clone <repository_url>

2. Check Repository Status:

git status

3. Stage Changes:

git add <file_name>

4. Commit Changes:

git commit -m "Commit message"

5. Push Commits to Remote:

git push origin <branch_name>

6. Pull Latest Changes:


git pull origin <branch_name>

7. Create a New Branch:

git checkout -b <new_branch_name>

8. Switch Branches:

git checkout <branch_name>

9. Merge Branches:

git checkout <target_branch>


git merge <source_branch>

Working with Remote:

1. Add a Remote Repository:

git remote add <remote_name> <repository_url>

2. List Remote Repositories:

git remote -v

3. Push Branch to Remote:

git push <remote_name> <branch_name>


Viewing History and Differences:

1. View Commit History:

git log

2. View Changes in a Specific Commit:

git show <commit_hash>

3. View Differences Between Branches:

git diff <branch1>..<branch2>

Undoing Changes:

1. Undo Last Commit (Keep Changes):

git reset HEAD~1

2. Discard Changes in Working Directory:

git checkout -- <file_name>

Advanced Topics:
1. Rebase Interactive Mode (Combine, Edit, Reorder Commits):

git rebase -i <base_commit>


2. Cherry-pick a Commit from Another Branch:

git cherry-pick <commit_hash>

3. Stash Changes:

git stash
git stash pop

you can explore more advanced commands and strategies. It's also
recommended to refer to the official Git documentation for a comprehensive
understanding: https://git-scm.com/docs

You might also like