Skip to content

TuShArBhArDwA/github_basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Git Commands Overview

A beginner-friendly guide to essential Git commands with clear explanations and examples.

Git Clone

The git clone command is used to download the source code from a remote repository (like GitHub, Bitbucket, or GitLab).

Using Git Clone Command:

git clone <https://url-of-the-repository>

When you clone a repo, the code is automatically downloaded to your local machine.

Git Status

This command shows which files are modified, untracked, or staged.

git status

Git Add

Every time you create, delete, or modify a file, you must stage it using git add.

git add <file-name>

To add all modified files:

git add -A

Note: git add only stages changes. It does not save them permanently or push them anywhere.

Git Commit

Think of the Git Commit command like a checkpoint in your development process.

Commit all staged changes:

git commit

Commit all tracked files directly:

git commit -a

Commit with a message:

git commit -am "<commit-message>"

Note: Commits are stored only in your local repository until you push them.

Git Push

Push your committed changes to the remote repository:

git push <remote> <branch-name>

Only committed changes will be pushed.

Git Pull

Download and merge the latest changes from the remote repo into your local branch:

git pull <remote> <branch-name>

Git Branch

Branches allow you to work on different features independently.

Create a new branch:

git branch <branch-name>

Switch to an existing branch:

git checkout <branch-name>

Create and switch to a new branch:

git switch -c <branch-name>

List all branches:

git branch

Git Merge

Merge another branch into your current branch:

git merge <branch-name>

Git Log

View commit history:

git log

Git Remote

View connected remote repositories:

git remote -v

Git Stash

Temporarily save uncommitted changes:

git stash

Restore them later:

git stash pop

Git Reset (Use Carefully!)

Undo commits or remove changes.

Undo last commit but keep changes:

git reset --soft HEAD~1

Undo last commit AND delete changes permanently:

git reset --hard HEAD~1

⚠️ Be careful: --hard removes changes permanently.

Sponsor

If you find this helpful, consider supporting me:

License

Contact

Releases

No releases published

Packages

No packages published