Git cheat sheet

Setting up Git
git config –global user.name “Your Name” : Set your Git username
git config –global user.email “youremail@example.com” : Set your Git email address
git config –list : List all Git configuration settings

Creating a new repository
git…


This content originally appeared on DEV Community and was authored by ZAMZAM

Setting up Git
git config --global user.name "Your Name" : Set your Git username
git config --global user.email "youremail@example.com" : Set your Git email address
git config --list : List all Git configuration settings

Creating a new repository
git init : Create a new local repository
git clone [url]: Clone an existing repository from a remote source

Adding and committing changes
git add [file] : Add changes to the staging area
git add . : Add all changes to the staging area
git commit -m "Commit message" : Commit changes to the local repository with a message

Working with branches
git branch: List all branches
git branch [branch-name]: Create a new branch
git checkout [branch-name]: Switch to a specific branch
git merge [branch-name] : Merge changes from a specific branch into the current branch
git push origin [branch-name] : Push changes to a remote repository

Working with remote repositories
git remote add origin [url] : Add a remote repository
git pull : Fetch and merge changes from a remote repository
git push : Push changes to a remote repository
git remote -v : List all remote repositories

Other helpful commands
git status: Show the status of your repository
git log : Show the commit history of your repository
git diff [file]: Show the changes made to a specific file.

These are some of the most commonly used Git commands. I hope this cheat sheet helps you in your Git journey!


This content originally appeared on DEV Community and was authored by ZAMZAM


Print Share Comment Cite Upload Translate Updates
APA

ZAMZAM | Sciencx (2023-04-29T21:39:24+00:00) Git cheat sheet. Retrieved from https://www.scien.cx/2023/04/29/git-cheat-sheet-2/

MLA
" » Git cheat sheet." ZAMZAM | Sciencx - Saturday April 29, 2023, https://www.scien.cx/2023/04/29/git-cheat-sheet-2/
HARVARD
ZAMZAM | Sciencx Saturday April 29, 2023 » Git cheat sheet., viewed ,<https://www.scien.cx/2023/04/29/git-cheat-sheet-2/>
VANCOUVER
ZAMZAM | Sciencx - » Git cheat sheet. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/29/git-cheat-sheet-2/
CHICAGO
" » Git cheat sheet." ZAMZAM | Sciencx - Accessed . https://www.scien.cx/2023/04/29/git-cheat-sheet-2/
IEEE
" » Git cheat sheet." ZAMZAM | Sciencx [Online]. Available: https://www.scien.cx/2023/04/29/git-cheat-sheet-2/. [Accessed: ]
rf:citation
» Git cheat sheet | ZAMZAM | Sciencx | https://www.scien.cx/2023/04/29/git-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.