Useful Git Commands for developer

I’ve searched a lot on Google how to do certain git actions, and this actually motivated me to write this post. This may not be so useful for a person who is a PRO in git, but I tried to list out all the git commands which will definitely benefit a newbie.

Here are the list of git commands which is going to get covered in this Post:

  • Clone
  • Stash Changes
  • List stashes
  • Apply stash
  • List branches
  • Create Branch
  • Commit
  • Push
  • Pull
  • Checkout Branch
  • Config
  • Ignore Filemode changes

Git Clone:
git clone [url]

Git clone with custom directory name:
git clone [url] [directory name]

Git Clone with password:
git clone https://username:password@xyz.com/abc/repository.git

Stash Changes:
git stash save

git stash save [stash name]

This command stash changes with name

List all stashes:
git stash list

Apply a stash:
git stash pop

git stash apply

List branches:
git branch

Note:  The one which is highlighted is the current branch

Create Branch:
git branch [branch name]

Commit:
git commit -m “[ commit message]”

Push changes:
git push origin [branch name]

Pull changes:
git pull origin [branch name]

Checkout branch:
git fetch && git checkout [branch name]

Config:
git config –global user.name [name]

git config –global user.email [email address]

This command sets the author name and email address to be used with your commits.

Ignore File mode changes:
git config core.fileMode false

If you want to know some more essential git commands, mention it in comments. I will post them also. If you know the commands which I didn’t mention in this post, you can post it in comments. I am always open to learning.

Kayalvizhi Ganesan

Web developer, Blogger, You-tuber and a learner. I am always open up for learning new things and sharing it with people. This Blog is to share the things which I have learnt. My goal is to help TYRO to become a PRO

Leave a Reply

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