user-manual: listing commits reachable from some refs not others
This is just an amusing example raised by someone in irc. Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
J. Bruce Fields committed
May 13, 2007 at 22:58 UTC
629d9f785fecb964245dac52b422aec0bd00278e
1 file changed
+48
Documentation/user-manual.txt
+48
@@ -830,6 +830,54 @@ available
830
Which shows that e05db0fd is reachable from itself, from v1.5.0-rc1, and
831
from v1.5.0-rc2, but not from v1.5.0-rc0.
832
833
+[[showing-commits-unique-to-a-branch]]
834
+Showing commits unique to a given branch
835
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
836
+
837
+Suppose you would like to see all the commits reachable from the branch
838
+head named "master" but not from any other head in your repository.
839
+
840
+We can list all the heads in this repository with
841
+gitlink:git-show-ref[1]:
842
+
843
+-------------------------------------------------
844
+$ git show-ref --heads
845
+bf62196b5e363d73353a9dcf094c59595f3153b7 refs/heads/core-tutorial
846
+db768d5504c1bb46f63ee9d6e1772bd047e05bf9 refs/heads/maint
847
+a07157ac624b2524a059a3414e99f6f44bebc1e7 refs/heads/master
848
+24dbc180ea14dc1aebe09f14c8ecf32010690627 refs/heads/tutorial-2
849
+1e87486ae06626c2f31eaa63d26fc0fd646c8af2 refs/heads/tutorial-fixes
850
+-------------------------------------------------
851
+
852
+We can get just the branch-head names, and remove "master", with
853
+the help of the standard utilities cut and grep:
854
+
855
+-------------------------------------------------
856
+$ git show-ref --heads | cut -d' ' -f2 | grep -v '^refs/heads/master'
857
+refs/heads/core-tutorial
858
+refs/heads/maint
859
+refs/heads/tutorial-2
860
+refs/heads/tutorial-fixes
861
+-------------------------------------------------
862
+
863
+And then we can ask to see all the commits reachable from master
864
+but not from these other heads:
865
+
866
+-------------------------------------------------
867
+$ gitk master --not $( git show-ref --heads | cut -d' ' -f2 |
868
+ grep -v '^refs/heads/master' )
869
+-------------------------------------------------
870
+
871
+Obviously, endless variations are possible; for example, to see all
872
+commits reachable from some head but not from any tag in the repository:
873
+
874
+-------------------------------------------------
875
+$ gitk ($ git show-ref --heads ) --not $( git show-ref --tags )
876
+-------------------------------------------------
877
+
878
+(See gitlink:git-rev-parse[1] for explanations of commit-selecting
879
+syntax such as `--not`.)
880
+
881
[[making-a-release]]
882
Creating a changelog and tarball for a software release
883
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~