Git Commands

Posted on Posted in Git

 Create a new Git repository

git init

Inspect the contents of the working directory and staging area

git status

Add files from the working directory to the staging area

git add

Show the difference between the working directory and the staging area (the commit HEAD)

git diff

Permanently store file changes from the staging area in the repository

git commit

 Show a list of all previous commits

git log

Show recent commit.

git show HEAD –

Reset all local working commits to the commit version

git reset HEAD –

If you committed a file and make changes  you wish to take back.

git reset HEAD <FILENAME> –

Discard any changes and be at the latest update in the HEAD.

git checkout HEAD –

Checkout only the file.

git checkout HEAD <FILENAME>

Resets to the previous SHA ID from the git log command

git reset SHA_ID

Show remote urls

git remote -v

Show both local refs and remote references

git show-ref

Setting your username and email – so that git knows who you are when commiting

 

git config –global user.email “user@hotmail.co.uk”
git config –global user.name “the users desktop”

Leave a Reply

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