Useful Commands

Reading Time: 1

GIT Cheatsheet

To initialise (create) a git repository
git init
Add files to the branch
git add –all
Commit files
git commit -m “initial commit”
Add remote repo
git remote add origin https://github.com/<username>/<repo>.git
Push commit to the remote repo
git push -u origin master
Check status
git status
Check current branch
git branch
Change branch
git checkout <branch_name>
Pull changes from origin (remote branch) to master (local branch)git pull origin master
For different repo histories useĀ –allow-unrelated-histories flag
Create a tag (annotated)
git tag -a <tag> -m “<tag comment>”
View tags on a branch
git tag
Search for a specific tag on a branch
git tag -l “<tag>”
Wildcard (*) search can be used within the quotes (“)