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<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 (“)

Leave a Reply

Your email address will not be published. Required fields are marked *