第七課 Git差異比對
$ vim README
$ git add README
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: lib/simplegit.rb
#
diff --git a/lib/simplegit.rb b/lib/simplegit.rb
index dd5ecc4..8ac6604 100644
--- a/lib/simplegit.rb
+++ b/lib/simplegit.rb
@@ -25,6 +25,10 @@ class SimpleGit
command("git log -n 25 #{treeish}")
end
+ command("git log --pretty=oneline #{branch}")
+ end
+
def blame(path)
command("git blame #{path}")
end
diff --git a/README b/README
index c526f88..879f0d4 100644
--- a/README
+++ b/README
@@ -8,3 +8,4 @@ It is an example for the Git Peepcode book that I'm currently writin
Author : Scott Chacon ([email protected])
Orange Peel Chacon ([email protected])
Magnus O. Chacon ([email protected])
+ Josephine Chacon ([email protected])
diff --git a/README b/README
index c526f88..879f0d4 100644
--- a/README
+++ b/README
@@ -8,3 +8,4 @@ It is an example for the Git Peepcode book that I'm currently writin
Author : Scott Chacon ([email protected])
Orange Peel Chacon ([email protected])
Magnus O. Chacon ([email protected])
+ Josephine Chacon ([email protected])
diff --git a/lib/simplegit.rb b/lib/simplegit.rb
index dd5ecc4..8ac6604 100644
--- a/lib/simplegit.rb
+++ b/lib/simplegit.rb
@@ -25,6 +25,10 @@ class SimpleGit
command("git log -n 25 #{treeish}")
end
+ command("git log --pretty=oneline #{branch}")
+ end
+
def blame(path)
command("git blame #{path}")
end
diff --git a/README b/README
index 548142c..5fa41b7 100644
--- a/README
+++ b/README
@@ -24,7 +24,7 @@ It was originally written by Linus Torvalds with help of a group o
hackers around the net. It is currently maintained by Junio C Hamano.
-See Documentation/tutorial.txt to get started, then see
+See Documentation/gittutorial.txt to get started, then see
Documentation/everyday.txt for a useful minimum set of commands,
and "man git-commandname" for documentation of each command.
Documentation/RelNotes-1.6.1.2.txt | 39 +++++++++++++
Documentation/config.txt | 4 +-
Documentation/git-ls-tree.txt | 8 +++-
GIT-VERSION-GEN | 2 +-
RelNotes | 2 +-
builtin-commit.c | 6 ++
builtin-gc.c | 8 ++-
builtin-grep.c | 15 +++++-
builtin-log.c | 28 +++++++++-
builtin-ls-tree.c | 7 ++-
builtin-send-pack.c | 43 +++++++--------
diffcore-rename.c | 9 +++-
git-sh-setup.sh | 2 +-
sha1_file.c | 3 +-
sha1_name.c | 2 +-
t/t2300-cd-to-toplevel.sh | 4 +-
t/t4014-format-patch.sh | 52 +++++++++++++++++-
t/t5519-push-alternates.sh | 106 ++++++++++++++++++++++++++++++++++++
t/t7002-grep.sh | 7 +++
test-path-utils.c | 2 +-
20 files changed, 306 insertions(+), 43 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 52d1ead..ce5ea12 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2337,7 +2337,8 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const c
static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
void *buf, unsigned long len, time_t mtime)
{
- int fd, size, ret;
+ int fd, ret;
+ size_t size;
unsigned char *compressed;
z_stream stream;
char *filename;
結果會顯示你給某個文件中添加了方法,還往README文件添加了一行內容。爲什麼會這樣?因爲對'dev'分枝來說,README文件還是原樣,而在'master'上,你已經刪掉了一行,這樣直接對兩個快照進行對比就好似'dev'分枝添加了一行進去一樣。你想查看的實際上是在創建dev分枝之後在這條分枝上的差異對比,所以應該執行這樣的命令:
這就不會拿master分枝上最後一個快照和dev分枝上最後一個快照進行比對--而是用dev與master所交的那個分歧點和現在的dev分枝上最後一個快照進行比對。在我們這個例子中,這樣比對的結果是顯示對那個文件添加了一個函數。如果你目前正處在master分枝上,你可以運行:
跟上面的結果是一樣的。所以,如果你想查看將要合併的某個分枝會有什麼樣的變化,可以執行:
將branch替換爲你想要合併的分枝名即可。