Top git cheat sheet for web developers

In this blog post I am going to share top git commands or you can call git cheatsheet. I will be listing commom git commands that you need while using git for version control during web development.

Git Cheatsheet:

1. Clone a git repo

Git clones clones an existing repository

git clone ssh://user@domain.com/repo.git
git clone https://git@github.com/repo.git
2. Create a local git repo

Create a local git repository

git init
3. List git branches

List local and remote git branches

git branch -a

OR

git branch --all
4. List git remote branches

List remote git branches

git branch -r

OR

git branch --remotes
5. Create a git branch

Create a local git branch out of current HEAD

git branch branchname
6. Checkout to a branch

Switch(checkout) to branch from current HEAD

git checkout branchname
7. Merge git branches

Merge a branch into another branch

git merge branch1name branch2name
8. Delete a local branch

Delete a local git branch

git branch -d branchname
9. Delete a remote branch

Delete a remote git branch

git push origin --delete remotebranchname
10. Git config username

Set author name to be used for all commits in current repo. Use –global flag to set config options for current user.

git config user.name username
git config --global user.name username
11. Undo changes

Discard all local changes in working directory

git reset --hard HEAD
Please follow and like us:
20

Add a Comment

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