With the -depth git will only download the content corresponding to the commits in the given range so the size of the repo will raise when the value is larger How does the value for depth correspond to the actual amount of data downloaded? # clone specific branch and limit the history to last X commits Meaning that your copy will have to all history, so you will be able to "switch" (checkout) to any commit you wish.Īdding the -depth limit the size fo your clone and checkout only the X last commits # Cloning a single branch with the following: depth means the number of commits to grab when you clone.īy default git download all your history of all branches. The suffix means all parents of the commit, but not the commit itself.) (Compare the above git rev-parse output with: $ git rev-parse instance. To get the hash IDs of the parents of ac0edf1f46 we can use: $ git rev-parse that gives us our six commits: the tip of master (which is currently a merge commit), two parents of that commit, one parent of one of those parents, and two parents of the other of that parent.ĭepending on precisely when you ran the clone of Git, the tip-most master is often not a merge, but often has a merge as its immediate parent, so that -depth 2 will often get you 3 commits, and -depth 3 will therefore get at least 5, depending on whether the two parents of the tip of master are themselves merges. The (lone) parent of ac0edf1f46 is not visible here, while the two parents of 5335669531 are (namely 6fcbad87d4 and 7e75a63d74). To add the depth-3 commits, we pick up all the parents of those two commits. With -depth 3, we start with 965798d1f2, then-for depth 2-pick up both parents, ac0edf1f669531. * | | 7e75a63d74 RelNotes 2.20: drop spurious double quote | * | 6fcbad87d4 rebase docs: fix incorrect format of the section Behavioral Differences * | 5335669531 Merge branch 'en/rebase-consistency' | * ac0edf1f46 range-diff: always pass at least minimal diff options * 965798d1f2 Merge branch 'es/format-patch-range-diff-fix-fix' With the Git repository for Git, however: $ git log -graph -oneline master If we use -depth 3 we'll pick up the tip commit cf68824, its parent 7c2376b at depth 2, and finally 95c8270 at depth 3-and then we stop, with three commits. * 80b88a5 add ruby gems directory to path * 26a9cc3 vimrc: fiddle with netrw directory display Suppose we have a commit graph that looks like this: $ git log -graph -oneline master The important point here is that the walk visits all parents of each commit, which-for each depth level-is more than one commit if the commit itself is a merge. As the documentation you quoted mentions, it also implies -single-branch, which simplifies talking about this. The -depth parameter refers to how deep Git goes on a "walk" from each starting point. (At work I observed the same thing with a GitLab server, so it can't be an artifact of how GitHub works.)ĭoes anybody know what is going on? How does the value for depth correspond to the actual amount of data downloaded? Do I understand the documentation wrongly, or is there a bug?Īs Jonathon Reinhart commented, you're seeing the effect of merges. |-|-|-|įor cloning I used this command git clone -depth 10, git clone -depth 100, and for counting the commits I used this git log -oneline | wc -l. This is what I got when I tried different values for depth: | depth | commit count linux repo | commit count git repo | This would indicate that will equal the number of commits that will be fetched during the clone, but it's not the case. If you want to clone submodules shallowly, also pass -shallow-submodules. single-branch unless -no-single-branch is given to fetch the histories near the tips of allīranches. This is what help for git clone says about it: -depth Ĭreate a shallow clone with a history truncated to the specified number of commits. I did some experiments with -depth parameter for clone and encountered some weird behavior. Rewriting git's history just to get rid of them seems like too much trouble, so we figured doing a shallow clone that avoided those big early commits would be good enough. Somebody committed some huge (by git's standards) binaries early in the project's life. We tried to speed up the CI build of one of our software projects at work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |