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

Github Basic Commands 1707840360

The document provides an overview of popular Git commands for version control and collaboration, including commands to clone a repository, create and switch branches, add and commit changes, push and pull from remote repositories, check the status and view commit history.

Uploaded by

Suraj JP
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Github Basic Commands 1707840360

The document provides an overview of popular Git commands for version control and collaboration, including commands to clone a repository, create and switch branches, add and commit changes, push and pull from remote repositories, check the status and view commit history.

Uploaded by

Suraj JP
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction to Github

Commands
This section will provide an overview of some popular Github commands
for efficient version control and collaboration.

S by Santosh H
Cloning a Repository
Steps to Clone a Repository Key Points
1. Navigate to the repository on Github. Cloning allows you to create a local copy of the
repository to work on.
2. Click on the "Code" button and copy the URL.
It's the first step in making contributions to
3. Open your terminal and use the command "git
open-source projects or collaborating with team
clone [URL]" to clone the repository to your local
members.
machine.
Creating a New Branch
1 Reasons to Create a New Branch 2 Steps to Create a New Branch
To work on a new feature without affecting 1. Use the command "git checkout -b
the main project code. [branchname]" to create and switch to a
new branch simultaneously.
Adding and Committing Changes
1 Add Changes
Use "git add ." to stage all changes for the next commit.

2 Commit Changes
Execute "git commit -m 'commit message'" to save staged changes to the
local repository.

3 Need for Good Commit Messages


Commit messages should be descriptive, concise, and focused on the
specific changes made.
Pushing Changes to a Remote
Repository
1 2 3

Add Remote URL Push to Remote View Changes on


Link the local repository to Once linked, use "git push
Github
the remote repository using origin [branchname]" to push Check the remote repository
"git remote add origin [URL]". changes to the remote on Github to see the reflected
repository. changes.
Pulling Changes from a Remote
Repository
Steps to Pull Changes Importance of Pulling Changes

1. Use "git pull origin [branchname]" to fetch and Pulling ensures that your local repository is up to
merge changes from the remote repository to date with the latest changes made by other
the local repository. collaborators.

2. Resolve any merge conflicts if they arise.


Checking the Status of a Repository
1 Viewing the Status 2 Interpreting Status Messages
Use "git status" to check the current Status messages provide valuable
state of the repository, including insights into the changes and the
tracked, untracked, and modified next steps to be taken.
files.
Viewing Commit History

100 3K 4
Total Commits Active Contributors Branches Merged
View the total number of Identify the number of unique Determine the count of merged
commits made to the contributors who have made branches by running "git branch
repository using "git log -- commits to the repository with --merged | wc -l".
oneline | wc -l". the command "git shortlog -s |
wc -l".

You might also like