Skip to content

Instantly share code, notes, and snippets.

@tiborvass
Last active August 29, 2015 14:14
Show Gist options
  • Save tiborvass/a0390907729dedb0ad3c to your computer and use it in GitHub Desktop.
Save tiborvass/a0390907729dedb0ad3c to your computer and use it in GitHub Desktop.
git mdiff example
$ cat ~/.gitconfig | tail -2
[alias]
mdiff = "!f() { git stash | head -1 | grep -q 'No local changes to save'; x=$?; git merge --no-commit $1 &>/dev/null; git add -u &>/dev/null; git diff --staged; git reset --hard &>/dev/null; test $x -ne 0 && git stash pop &>/dev/null; }; f"
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: hello
Untracked files:
(use "git add <file>..." to include in what will be committed)
untracked
no changes added to commit (use "git add" and/or "git commit -a")
$ git mdiff bob
diff --git a/goodbye b/goodbye
new file mode 100644
index 0000000..cc628cc
--- /dev/null
+++ b/goodbye
@@ -0,0 +1 @@
+world
diff --git a/hello b/hello
index cc628cc..0554dbf 100644
--- a/hello
+++ b/hello
@@ -1 +1,5 @@
+<<<<<<< HEAD
world
+=======
+earth
+>>>>>>> bob
diff --git a/test.js b/test.js
index d3358c8..6a39681 100644
--- a/test.js
+++ b/test.js
@@ -7,6 +7,7 @@ function calculateAirfare(baseFare) {
var fare = baseFare;
fare += customsFee;
fare += immigrationFee;
+ fare += customsFee;
fare *= (1 + federalTransportTax);
return fare;
}
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: hello
Untracked files:
(use "git add <file>..." to include in what will be committed)
untracked
no changes added to commit (use "git add" and/or "git commit -a")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment