Git Commands Cheat Sheet

Git is a distributed version control system (DVCS) that allows multiple developers to collaborate on a project, tracking changes to files and coordinating work seamlessly.

Initializing a Repository:

git init

Cloning a Repo…


This content originally appeared on DEV Community and was authored by Madhav Ganesan

Git is a distributed version control system (DVCS) that allows multiple developers to collaborate on a project, tracking changes to files and coordinating work seamlessly.

Initializing a Repository:

git init

Cloning a Repository:

git clone -b <branch-name> <url> <folder-name>

Working with Branches:

Create a new branch:

git checkout -b <new-branch>

Switch branches:

git checkout <branch-name>

List all branches:

git branch

Staging and Committing Changes:

Add files to staging area:

git add .

Commit changes:

git commit -m "message"

View changes before staging:

git diff

Remote Repositories:

Add a remote repository:

git remote add origin <remote-repository-URL>

List all remotes:

git remote -v

Push changes to a remote repository:

git push -u origin <branch-name>

Pull changes from a remote repository:

git pull origin <branch-name>

Stashing Changes:

Stashing in Git allows you to temporarily save changes that are not yet ready to be committed, so we can switch to another branch without losing your progress. It is used when you need to quickly switch contexts or update your working directory without committing incomplete work.

Stash changes:

git stash

Apply stashed changes:

git stash apply

Configuration:

Change user name:

git config --global user.name "name"

Change user email:

git config --global user.email "email"


This content originally appeared on DEV Community and was authored by Madhav Ganesan


Print Share Comment Cite Upload Translate Updates
APA

Madhav Ganesan | Sciencx (2024-06-18T14:08:17+00:00) Git Commands Cheat Sheet. Retrieved from https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/

MLA
" » Git Commands Cheat Sheet." Madhav Ganesan | Sciencx - Tuesday June 18, 2024, https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/
HARVARD
Madhav Ganesan | Sciencx Tuesday June 18, 2024 » Git Commands Cheat Sheet., viewed ,<https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/>
VANCOUVER
Madhav Ganesan | Sciencx - » Git Commands Cheat Sheet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/
CHICAGO
" » Git Commands Cheat Sheet." Madhav Ganesan | Sciencx - Accessed . https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/
IEEE
" » Git Commands Cheat Sheet." Madhav Ganesan | Sciencx [Online]. Available: https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/. [Accessed: ]
rf:citation
» Git Commands Cheat Sheet | Madhav Ganesan | Sciencx | https://www.scien.cx/2024/06/18/git-commands-cheat-sheet-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.