Tuesday 10 September 2019

GIT Command reference

Below is list of git commands for quick reference

Initialize git with new Folder

git init [ProjectFolder] 
example - git init sample-git-demo

Initialize git with existing Folder
Navigate to existing folder and execute git init

Display modified files in the working directory vs Git's staging area.
git status

Add new or newly modified filename to Git's staging area
git add [filename]
To add recursively all new and newly modified files.
git add .

Commits all files in Git's staging area
git commit -m "First Commit to git"

Below command to directly commit newly modified already committed files
git commit -am "Second Commit to git"

Reset File from Git's staging area
git reset HEAD [filename]

Checkout last committed version from Git
git checkout -- [filename]

Display Git log history
git log

Creating a remote repository reference
git remote add origin [full URL for the remote repository]

List Git's Remote repos
git remote -v

Send Changes to Remote - The -u parameter is needed the first time
git push -u [RemoteName] [BranchName]
git push [RemoteName] [BranchName]

Receive Changes from Remote

git push [RemoteName] [BranchName]

No comments:

Post a Comment

Make life easier — Git automation with single command file

Make life easier — Git automation with single command file Posted on medium #makelifeeasier series - Automation of git related activity...