File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ _317 TILs and counting..._
7575- [ Determine The Hash Id For A Blob] ( git/determine-the-hash-id-for-a-blob.md )
7676- [ Dry Runs in Git] ( git/dry-runs-in-git.md )
7777- [ Excluding Files Locally] ( git/excluding-files-locally.md )
78+ - [ Find The Initial Commit] ( git/find-the-initial-commit.md )
7879- [ Grab A Single File From A Stash] ( git/grab-a-single-file-from-a-stash.md )
7980- [ Grep Over Commit Messages] ( git/grep-over-commit-messages.md )
8081- [ Ignore Changes To A Tracked File] ( git/ignore-changes-to-a-tracked-file.md )
Original file line number Diff line number Diff line change 1+ # Find The Initial Commit
2+
3+ By definition, the initial commit in a repository has no parents. You can
4+ exploit that fact and use ` rev-list ` to find the initial commit; a commit
5+ with no parents.
6+
7+ ``` bash
8+ $ git rev-list --max-parents=0 HEAD
9+ ```
10+
11+ The ` rev-list ` command lists all commits in reverse chronological order. By
12+ restricting them to those with at most 0 parents, you are only going to get
13+ root commits. Generally, a repository will only have a single root commit,
14+ but it is possible for there to be more than one.
15+
16+ See ` man git-rev-list ` for more details.
You can’t perform that action at this time.
0 commit comments