0

I have an empty git repo and I want to fetch commit by commit from a remote repo. For example, I do

git init
git remote add origin https://github.com/torvalds/linux.git
git pull --no-edit -s recursive -X theirs . 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2

However, doing so gives me an error fatal: no matching remote head. I'm wondering if fetching commit one by one from scratch is possible using git?

Put the question in another way. I want to simulate git clone but instead of git clone fetching all commits, I want to get commit one by one, which allows me to perform some other work in-between.

Thanks!

xxks-kkk
  • 1,743
  • 3
  • 21
  • 39
  • 2
    even it it were possible, what do you want to achieve that is not possible to do by fetching everything at once? – eftshift0 Oct 29 '18 at 19:32
  • Possible duplicate of [Retrieve specific commit from a remote Git repository](https://stackoverflow.com/questions/14872486/retrieve-specific-commit-from-a-remote-git-repository) – Jonathan.Brink Oct 29 '18 at 19:33
  • @eftshift0 I'm doing a scientific experiment with this setup is a must and I don't think my purpose is relevant to this question. – xxks-kkk Oct 29 '18 at 19:53
  • @Jonathan.Brink Thanks for the suggestion. I don't think my question is duplicate because I tried to start from scratch and fetch commit one by one (possibly, no `fetch` or `clone` involved) – xxks-kkk Oct 29 '18 at 19:55
  • I believe that you may have confused the purpose of fetch and pull. If you are wanting to see where individual files are at for a commit, use a pull, pointing to a specific change set, otherwise, you can fetch to have git's knowledge of the current origin updated to have everything that is currently in origin. – dmoore1181 Oct 29 '18 at 19:57
  • @dmoore1181 Thanks for the comment. I want to do `git pull` to simulate patching source files. – xxks-kkk Oct 29 '18 at 19:58
  • 1
    You said you're doing a scientific experiment, however it's unclear what you're trying to test. Why would `git fetch origin` followed by `git cherry-pick ` not work, where cherry-picking actually is "patching source files"? You should probably add those details to the description. – alfunx Oct 29 '18 at 20:48
  • Also, note that `git pull` is just `git fetch` followed by `git merge`. You can simply fetch everything at once, then merge one commit at a time the way you would have `pull`ed one commit at a time, without bothering to `fetch` again. This will be much faster as you'll skip the "contact the other Git" step. Meanwhile, note that the remote name `.` means "myself", so as expressed, this says to create an empty repository, then fill it from itself, which won't do much good either. – torek Oct 29 '18 at 21:07

0 Answers0