0% found this document useful (0 votes)
4 views2 pages

Git Beginners Guide

This document serves as a beginner's guide to essential Git commands for setting up a repository, managing changes, and collaborating with others. It covers commands for initializing a repository, cloning, adding and committing changes, pushing and pulling from remote repositories, branching, merging, and undoing changes. Additionally, it includes useful tips for managing branches and checking commit logs.

Uploaded by

jc.dandu
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)
4 views2 pages

Git Beginners Guide

This document serves as a beginner's guide to essential Git commands for setting up a repository, managing changes, and collaborating with others. It covers commands for initializing a repository, cloning, adding and committing changes, pushing and pulling from remote repositories, branching, merging, and undoing changes. Additionally, it includes useful tips for managing branches and checking commit logs.

Uploaded by

jc.dandu
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/ 2

Beginner's Guide to Git Commands

1. Setup (First-Time Only)

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

Sets your name and email for commits.

2. Create or Initialize a Repository

git init

Creates a new Git repository in your project folder.

3. Clone a Repository

git clone https://github.com/user/repo.git

Makes a local copy of a remote Git repository.

4. Add and Commit Changes

git status # Shows modified files

git add filename # Add one file

git add . # Add all files

git commit -m "Your commit message" # Save changes with message

5. Push to Remote Repository

git push origin main

Push your changes to the main branch.

6. Pull Changes from Remote

git pull origin main

Gets latest changes from remote and merges.

7. Branching

git branch # List branches

git branch new-branch # Create branch

git checkout new-branch # Switch to branch


8. Merge Branch

git checkout main # Go to main branch

git merge new-branch # Merge changes

9. Remove Files

git rm filename

git commit -m "Removed file"

10. Undo Changes

git checkout -- filename # Discard changes

git reset HEAD filename # Unstage file

git reset --hard # Reset everything (Be careful!)

Bonus: Useful Git Tips

git log # Check commit log

git remote -v # Check remote URLs

git branch -m new-name # Rename branch

git branch -d branch-name # Delete branch

You might also like