Is there a way to see with git log
or some other command only the commits that were added after branch creation?
usage: git log [<options>] [<since>..<until>] [[--] <path>...] or: git show [options] <object>... --quiet suppress diff output --source show source --decorate[=...] decorate options
On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.
The git log command displays all of the commits in a repository's history.
The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.
Using git log By default, git log shows a lot of info about each commit—the ref ID, the author, the date, the commit message, and if it's the HEAD of any branches. If you'd like to know what files are affected, you'll need to run it with --stat , which will display a list of files with additions and deletions.
Full documentation is here: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html
Suppose you have a repo that looks like this:
base - A - B - C - D (master) \ \- X - Y - Z (myBranch)
Verify the repo status:
> git checkout master Already on 'master' > git status ; git log --oneline On branch master nothing to commit, working directory clean d9addce D 110a9ab C 5f3f8db B 0f26e69 A e764ffa base
and for myBranch:
> git checkout myBranch > git status ; git log --oneline On branch myBranch nothing to commit, working directory clean 3bc0d40 Z 917ac8d Y 3e65f72 X 5f3f8db B 0f26e69 A e764ffa base
Suppose you are on myBranch, and you want to see only changes SINCE branching from master. Use the two-dot version:
> git log --oneline master..myBranch 3bc0d40 Z 917ac8d Y 3e65f72 X
The three-dot version gives all changes from the tip of master to the tip of myBranch. However, note that the common commit B is not included:
> git log --oneline master...myBranch d9addce D 110a9ab C 3bc0d40 Z 917ac8d Y 3e65f72 X
PLEASE NOTE: git log
and git diff
BEHAVE DIFFERENTLY! The behavior is not exactly opposite, but almost:
> git diff master..myBranch diff --git a/rev.txt b/rev.txt index 1784810..e900b1c 100644 --- a/rev.txt +++ b/rev.txt @@ -1 +1 @@ -D +Z > git diff master...myBranch diff --git a/rev.txt b/rev.txt index 223b783..e900b1c 100644 --- a/rev.txt +++ b/rev.txt @@ -1 +1 @@ -B +Z
So, the two-dot version shows the diff from tip of master (i.e. D) to tip of myBranch (Z). The three-dot version shows the difference from the base of myBranch (i.e. B) to the tip of myBranch (Z).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With