Git Commands

Need Help: git help

Check Version: git –-version

Check the status: git status (it will be better to type this command repeatedly )

Create a Branch for Desired Feature:

command 1: git branch branchName

command 2: git checkout branchName

command 3: git status

Merge a Branch:

command 1: git checkout master      // now ready to merge those changes, need to checkout to master.

command 2: git pull origin master      // pull all the changes that have been made since our last pull.

command 3: git merge branchName      //merging with your master.

command 4: git push origin master      //push the changes.

Deleting the Branch

command 1: git branch --merged

command 2: git branch -d branchName

command 3: git branch -a

command 4: git push origin --delete branchName

Cloning a Remote Repository

Command 1: git clone path or URL      (where to clone)

Eg: git clone git://…….git

Add files to Staging Area

command 1: git add –A

command 2: git commit –m “Provide the information about the changes you have done”

Add remote from original repository to your forked repository

command 1: git remote add upstream git://……...git

command 2: git remote –v

command 3: git fetch upstream

command 4: git merge upstream/master

Clear the Changes: git reset --hard [commit]

Discarding unstages Changes: git reset [file]

Get the changes from the git hub account: git pull origin master

Push the changes to the git hub account: git push origin master