# Diff & Merge

## Install & Configure p4merge diff tool on Linux

```
// Download 1st https://www.perforce.com/downloads/visual-merge-tool
// .tgz file downloaded
gunzip p4v.tgz ( create .tar )
tar xvf p4v.tar

cd p4v-...( extracted folder )
mkdir /opt/p4merge
mv * /opt/p4merge
// create sumbolic link
ln -s /opt/p4merge/bin/p4merge /usr/local/bin/p4merge 
// OR
ln -s /opt/p4merge/bin/p4merge /usr/bin/p4merge 
p4merge ( it will launch p4merge tool )
```

## Configuring diff & merge tool

```
git config --global diff.tool p4merge
git config --global difftool.p4merge.path /usr/bin/p4merge
git config --global difftool.prompt false
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path /usr/bin/p4merge
git config --global mergetool.prompt false

// test config now
git --config --global --list
```

```
git diff/difftool  HEAD( diff b/w working & staging )
git diff/difftool HEAD ( diff b/w working & last commit )
git diff <commit hash> HEAD ( latest and particular commit )

// HEAD^ or HEAD~1 just prior to HEAD
git diff HEAD^ HEAD ( diff b/w HEAD & HEAD-1)

// Diff b/w any 2 commit
git diff <commit hash 1> <commit hash 2>

// Diff between Local & Remote master
// master -> local master, origin/master -> Remote (github) master
git diff master origin/master

// Diff between local master & local any branch
git diff master feature-branch
```
