Skip to content

Commit 1c5b502

Browse files
committed
More details on git diff
1 parent 9c7aae2 commit 1c5b502

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ minimal guide to get started.
2121
- [Contribute to someone's repository](pages/fork.html): fork.
2222
- [Handling merge conflicts](pages/merge_conflicts.html).
2323
- [Oops; that last commit message was wrong](pages/amend_commit_msg.html).
24-
- [Exploring the code and its history](pages/exploring_code.html).
24+
- [Exploring the code and its history](pages/exploring_code.html):
25+
tag, diff
2526
- [Branching and merging](pages/branching.html).
2627
- [Other (much more thorough) resources](pages/resources.html).
2728

pages/exploring_code.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,70 @@ title: Exploring code and its history
44
---
55

66
For my own repositories, I like to use [gitx](http://gitx.frim.nl/) on
7-
my Mac.
7+
my Mac to explore the commit history.
88

99
But, of course, you can also just poke around
1010
[github](http://github.com) itself.
1111

1212
And you can do a lot of things from the command line, say to look at
1313
the combined changes to a file that were made over the last year.
14-
See the [github page about `git diff`](http://learn.github.com/p/diff.html).
14+
See the
15+
[github page about `git diff`](http://learn.github.com/p/diff.html).
16+
17+
### Tags
18+
19+
Each commit is assigned a “hash tag” which is a unique
20+
sequence of letters and numbers, like
21+
[4d9fe11e56652bd19e19e28eac3906f09d5a3074](https://github.com/kbroman/github_tutorial/commit/4d9fe11e56652bd19e19e28eac3906f09d5a3074).
22+
When you refer to these hash tags, you can just use an initial substr,
23+
like `4d9fe`, that is unique to your repository.
24+
25+
For my [R/qtl package](http://github.com/kbroman/qtl), I like to tag
26+
particular commits by the version number of the package, then I can
27+
use my assigned tag in place of the less memorable hash tag.
28+
29+
To assign a tag, use something like
30+
31+
git tag -a -m "Tagging version 1.28-5" 1.28-5
32+
33+
To push the tags to github, you need to use
34+
35+
git push --tags
36+
37+
To delete a tag, use
38+
39+
git tag -d 1.28-5
40+
41+
and then you need to remove the tag from github
42+
43+
git push origin :refs/tags/1.28-5
44+
45+
### More uses for diff
46+
47+
To see all of the changes since the last commit, type
48+
49+
git diff
50+
51+
To see all of the changes since a given commit, type
52+
53+
git diff [commit]
54+
55+
Where in place of `[commit]` you use the initial part of a hash tag,
56+
like `9f4668c`, or a tag you've created, like `1.28-1`.
57+
58+
To see all of the changes to a given file since a given commit, type
59+
60+
git diff [commit] [file]
61+
62+
For example,
63+
64+
git diff 1.22-21 R/scanone.R
65+
66+
To see all of the changes between two revisions, type something like
67+
68+
git diff 1.22-21 1.23-16
69+
70+
If you use [gitx](http://gitx.frim.nl/), you can use it to view the
71+
differences using a pipe:
72+
73+
git diff 1.22-21 1.23-16 | gitx

0 commit comments

Comments
 (0)