From: =?ISO-8859-15?Q?Dirk_S=FCsserott?= Subject: git-am with an initial checkin doesn't work Date: Tue, 14 Jul 2009 16:55:34 +0200 Message-ID: <4A5C9C66.1050100@dirk.my1.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit To: Git Mailing List X-From: git-owner@vger.kernel.org Tue Jul 14 16:55:47 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQjQ1-00085v-Ps for gcvg-git-2@gmane.org; Tue, 14 Jul 2009 16:55:46 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbZGNOzj (ORCPT ); Tue, 14 Jul 2009 10:55:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753811AbZGNOzi (ORCPT ); Tue, 14 Jul 2009 10:55:38 -0400 Received: from smtprelay11.ispgateway.de ([80.67.29.28]:55521 "EHLO smtprelay11.ispgateway.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbZGNOzi (ORCPT ); Tue, 14 Jul 2009 10:55:38 -0400 Received: from [84.176.107.73] (helo=[192.168.2.100]) by smtprelay11.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1MQjPq-0007H5-OX for git@vger.kernel.org; Tue, 14 Jul 2009 16:55:37 +0200 User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) X-Df-Sender: 757646 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Hi, I've a question concerning 'git am' and 'git format-patch'. It seems impossible to apply the "initial checkin" (as generated by git format-patch -N --root) to an empty repository. The following workflow might clarify that: # Create a new repository with an initial checkin: mkdir foo && cd foo && git init echo "initial checkin" > initial.checkin git add initial.checkin && git commit -m "initial checkin" # Kinda "export" the repo: git format-patch -1 --root; # generates 0001-initial-checkin.patch # Re-create the repository: rm -rf .git initial.checkin && git init # Try to "import" the patch: git am 0001-initial-checkin.patch The latter yields to fatal: HEAD: not a valid SHA1 fatal: bad revision 'HEAD' It works, when I git apply 0001-initial-checkin.patch instead of am'ing it, but then the thing isn't committed and I've to manually git-commit it. Is this a bug, intentional behavior, or am I missing some magic option to git-am? Background: I faced that problem when I tried to import some old data into Git (namely .tar.gz files) and wanted to start with 2 or 3 commits of my own (the import scripts) and then the other files on top of it. Because my import scripts didn't work well at first, I had to re-, re-, and re-import and start over all again. To always start with a clean repo, I thought adding my scripts and then saving them as 000N-*.patch would be a good idea, but the initial git-am didn't work. I know, there are other ways (git-rebase is a big friend here), but I thought git-format-patch and git-am worked symmetrically. Wrong? Cheers, Dirk