Git cheatsheet
Git is a distributed version control system that allows developers to collaborate on large or small projects.
This cheat sheet helps familiarise you with fundamental git commands.
Setting Git username:
git config --global user.name "Manideep"
Setting Git user email:
git config --global user.email "example@gmail.com"
Initialize Git repo :
git init
Adding file to staging area:
Single file
git add file_name
All files
git add .
Status of Git repository :
This will show you current repository status:
- Staged
- Unstaged
- Untracked files
git status
Commit changes:
git commit -m "Your message"
Commit history in Git :
git log
Remove tracked files current working tree in Git :
git rm filename
Ignore files in Git :
Create a
.gitignore
file, add the file names you want to ignore, and commit it.Creating a new branch in Git :
git branch branch_name
Switch branch :
git checkout branch_name
List of branches :
git branch
Create a new branch and switch to it :
git checkout -b branch_name
Delete a branch :
git branch -d branch_name
Merge branch with current branch :
git merge branch_name
Add a remote repository :
git add remote repoURL
List of remote URL :
git remote -v
Push your changes to remote repository :
git push
Pull changes from remote repository :
git pull
These commands will assist you in getting started with Git.
This is all from my side. Thanks for reading.