Git | Frequently used commands

To check for any changes in the files.

git status

View Change history and comments.

git log

To see the change history per file

git log -p

See changed files history

git log --stat

Commit the change

git commit -m "Message for commit"

To revert back a commit

git reset --soft HEAD~1

To create a clone of your local repository

git clone /.git

To create a bare clone(A clone with the .git database alone) as a central repository

git clone --bare /.git .git

To see remote branches

git remote -v

Add/remove a remote branch

git remote add  .git
git remote remove 

Push local changes to remote branch

git push -u 
git pull 

If you want to start tracking a remote branch with git status command, run below command.

git push -u  


After Git pull, if you encountered below output.

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

git pull

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/ master

—————

Sherbaz@SHERBAZ-PC /s/Softwares/Open Source/linuxKernel (master)
$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use “git add” to track)

—————-

$ git branch –set-upstream-to=Origin/master master
fatal: branch ‘master’ does not exist

—————-

$ git checkout -b master -t origin/master
error: unable to create file drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c (No s
uch file or directory)
Checking out files: 100{88dc7f9385b2c8971f38421926506de3e3fc5e843c9520f0674d4b7de6ae62da} (47503/47503), done.
D       drivers/gpu/drm/nouveau/core/subdev/i2c/aux.c
Branch master set up to track remote branch master from origin.
Already on ‘master’

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.