Monday, May 17, 2021

Git Basics - diff

 mate README.md

--------------------------------------------------------------------------

#Start Web Project


##Introduction


##Purpose



##Contribute

-----------------------------------------------------------------------------

git add README.md

git commit -m "adding readme file"

git push origin master


mate README.md --> add a new line ##Deployment

git commit -am "Adding new section:Deployment"

git status

nothing to commit, working directory clean

Comparing working directory and git repository

2. now add another line

mate README.md --> 

git add README.md


3. add another line

mate README.md --> 


git status

Changes to be committed:

modified: README.md

Changes not staged for commit:

modified: README.md

git diff --> without any parameters


This will out put difference between

1. What is in my local directory("Working directory") - currently modified

againts

2. What is been "Staged"

Press 'q' to quit

git difftool -> visually see the diff


git diff HEAD -> working directory and lat commit of the branch( working directory vs Staged)

same thing

git difftool HEAD

last commit and what is being change

git diff --staged HEAD (Staged area Vs Local Repo)

Limiting to one file

git diff -- README.md ( git diff -- {path to file}


Comparing between commits

We have 3 areas

1. Working Directory

2. Staged area

3. Local Repo

We need to see the diff. use diff command.

git diff {first} {second}

git log --online   --> history of the commits happens so far

you can get the hash from here for where you need to check diff

git diff a23412 HEAD


git diff HEAD HEAD^

git Repository at HEAD vs GIT repository at 1 commit before HEAD

git diff a23412 a2ed34


Comparing between Local and remote Master branches

1. Local Repository - master - (@HEAD)

2. Remote Repository - origin/master - (GitHub)

git diff master origin/master

origin - is the name to point remote repository -> GitHub

diff between what is committed(local) and what is in GitHub (pushed)

No comments:

Post a Comment