Git introduction and command cheat sheet

Git is a version control system, basically used for management of source code during software development. Licensed under GNU.




Git is easy to learn and use. I will walk you through few basic and most frequently used git commands during software development.

git

Basic git command cheat sheet

Check git version command: "git --version"
Initialise git in your local command: "git init"
Clone a git repo: "git clone <url>"
switching git branch: "git checkout <branch name>"
fetch and merge changes into current branch: "git pull"
check your local modifications: "git diff"
Add your local changes: "git add <file name>"
Add all files "git add ."
Commit git changes after add: "git commit -m"<commit message>" "
Push your local commit to remote: "git push origin <branchName>"
Git Clean untracked files: "git clean"
Git Clean untracked files force "git clean -f"
Stash git changes: "git stash"
Apply latest stashed changes: "git stash apply"
See all git stashed list: "git stash list"
Apply specific git stash: "git stash apply stash@{0}"
stash index can be found from stash list
git discard all local changes: "git checkout ."
git discard a specific file or folder change: "git checkout <filename|path>"
git remove or delete local branch: "git branch -d"
git undo local commit: "git reset --hard HEAD"

 

Leave a Reply

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