0% found this document useful (0 votes)
25 views20 pages

Github For Automation 1722068053

Uploaded by

8p66m44qmn
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)
25 views20 pages

Github For Automation 1722068053

Uploaded by

8p66m44qmn
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/ 20

All GitHub Concepts

For Test Automation Engineers

LinkedIN - Japneet Sachdeva


Cloning Repositories
git clone <repository_url>:

Copies a remote repository to your local machine

LinkedIN - Japneet Sachdeva


Managing Branches
git branch: Lists existing branches.

git checkout <branch_name>: Switches to a different branch.

git checkout -b <new_branch_name>: Creates a new branch and switches to it.

git merge <branch_name>: Combines changes from another branch into your
current branch.

LinkedIN - Japneet Sachdeva


Working with Files
git add <filename>: Adds a file to the staging area for the next commit.

git add .: Adds all changed files to the staging area.

git status: Shows the status of files in the repository (untracked, modified, staged).

LinkedIN - Japneet Sachdeva


Committing Changes
git commit -m "<commit_message>": Commits staged changes with a message.

LinkedIN - Japneet Sachdeva


Synchronizing with Remote
git pull origin <branch_name>: Fetches and merges changes from the remote
repository into your local branch.

LinkedIN - Japneet Sachdeva


Viewing History
git log: Shows a list of commits with information like author, date, and commit
message.

LinkedIN - Japneet Sachdeva


Using Tags
git tag <tag_name>: Creates a tag to mark a specific commit.

git push origin <tag_name>: Pushes a tag to the remote repository.

LinkedIN - Japneet Sachdeva


Resolving Conflicts
git mergetool: Launches a visual merge tool to resolve conflicts manually.

LinkedIN - Japneet Sachdeva


Reverting Changes
git revert <commit_hash>: Undoes the changes introduced by a specific commit.

LinkedIN - Japneet Sachdeva


To initialize a repository or create new git repository in
your local system

git init

LinkedIN - Japneet Sachdeva


What are the new changes and files updated in your
code

git status

LinkedIN - Japneet Sachdeva


How to push code to a remote repository?

i. First you need to authenticate yourself by using token or basic authentication

iii. After this you can create a repository on your github account

iii. Copy the http url, then use following

Command: git remote add origin <remote_url>

LinkedIN - Japneet Sachdeva


How to get status and updates made in remote branches

git diff origin/<branch_name>

LinkedIN - Japneet Sachdeva


How to remove files from the staging area?

git reset

How to create a git-ignore file?

Command: touch .gitignore (works in git-bash)

Terminal: git add .gitignore

LinkedIN - Japneet Sachdeva


How to search for text in the current working
repo/directory?

git grep <text>

How to create and move branch working directory (local)?

Command: git checkout -b <branch_name>

LinkedIN - Japneet Sachdeva


How to fetch the latest changes from remote to local?
Command: git pull origin master (branch_name)
How to save local changes made without committing or moving them to remote
repository?
Command: git stash
Hint: Used when you want to save local changes temporarily that are not yet
committed.
Its primary use is when you want to switch a branch or work on different task.

LinkedIN - Japneet Sachdeva


How to use stashed changes in git local repo so as to
commit to remote repository?
Command: git stash apply

Hint: Helps to use the changes which were stashed earlier. Make sure before
applying the changes you switch to the repository for which changes were made.

LinkedIN - Japneet Sachdeva


Git WorkFlow

LinkedIN - Japneet Sachdeva


For more interview questions and in depth
understanding use my courses, links available in my
profile.

Also subscribe to my Medium and YouTube channels -


Links in profile

Keep following - @Japneet Sachdeva - LinkedIN

LinkedIN - Japneet Sachdeva

You might also like