Friday, 12 February 2021

Git Commands init clone comit push pull reset hard reset soft and ammend log and status

 git init

git clone

git status

git diff index.html

+ means added 

- means deleted


unstaged and staged 

first whatever the changes it will add in 

unstaged area 

and then add the file  git add index.html

check git status for file in staged or unstaged ?


if it staged then comit the changes with some message 


git commit -m "Hello world "


git log 


whatever in the log changes with some id no 

Z:\freelance\zpp\git\makwell>git log

commit adcf8f261c015bf1cdf1dbbdcab31d8a0e867fd6 (HEAD -> master)

Author: BALA MURALI S <mur4l33@gmail.com>

Date:   Fri Feb 12 18:21:42 2021 +0530


git show adcf8f261c015bf1cdf1dbbdcab31d8a0e867fd6  

to view the exact changes in the file 



to check the specifi amunt of log


git log -5 


git branch

to check the branch 



To create a new branch 

git checkout -b "bbranch"


>git branch bbranch


to switch back to master branch 

>git checkout master


to delete the branch 

git branch -d ''bbranch"


git branch bbranch

git status 

git add

git comit 


to merge the  change to he master branch

first switch to master and then merge

git checkout master 

git merge bb

git checkout master 


do some changes on bb

comit onthat 


do delete the changes 


git reset --hard HEAD^



hard means comit and code both will get deleted 

soft means comit will get removed but code will remains there 

Z:\freelance\zpp\git\makwell>git reset --soft e7ba9fbc6d690a4ba5e1fda7939827719a7fd68e


Z:\freelance\zpp\git\makwell>git status

On branch bb

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        modified:   index.html


remote master


push  to remote branch or master 



git checkout master 


git status 


to restore

git restore --staged  "index.html"

git status 



git pull

git log


git push



git commit --amend 


click esc

:wq 

>enter



References:

Git handbook: https://guides.github.com/introductio... Download Git: https://git-scm.com/downloads


No comments:

Post a Comment