{"thread":{"id":"38743","subject":"Please consider adding a -f switch to git-clone (or something similar)","startedAt":"2015-03-07T21:54:25Z","lastAt":"2015-03-08T18:27:01Z","messageCount":7,"participants":["Diego Viola","Andreas Schwab","brian m. carlson","Kyle J. McKay"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"257239","messageId":"CA+ToGPEZN7TBcYF3o5YgbayjZ8WKok-fjTPeq5nbt2vAG1wDDQ@mail.gmail.com","threadId":"38743","inReplyTo":null,"subject":"Please consider adding a -f switch to git-clone (or something similar)","fromName":"Diego Viola","fromEmail":"diego.viola@gmail.com","sentAt":"2015-03-07T21:54:25Z","receivedAt":"2015-03-07T21:54:25Z","isPatch":false,"sender":{"key":"diego.viola@gmail.com","avatar":null},"body":"Hello,\n\nI was thinking about creating a new repository in my home dir so that I could\nkeep my dot files in it.\n\nHowever, I found that I can't do a `git clone url:user/repo.git .` in a\nnon-empty directory.\n\nIs there a possibility of implementing a -f switch to git-clone so that when I\nuse that, git would still clone the repo in the non-empty directory and keep the\nuntracked files untracked/unstaged? (just as if I copied files to the git repo).\n\nI know I could git-init in a empty directory and then copy the .git dir to the\nnon-empty directory as a workaround, but I like the idea of cloning better.\n\nMy C skills aren't that great or I would have sent a patch already.\n\nThanks,\n\nDiego\n"},{"id":"257240","messageId":"87d24kzbor.fsf@igel.home","threadId":"38743","inReplyTo":"CA+ToGPEZN7TBcYF3o5YgbayjZ8WKok-fjTPeq5nbt2vAG1wDDQ@mail.gmail.com","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2015-03-07T22:26:28Z","receivedAt":"2015-03-07T22:26:28Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Diego Viola <diego.viola@gmail.com> writes:\n\n> I know I could git-init in a empty directory\n\nYou can also git init a non-empty directory.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"257241","messageId":"20150307225314.GC742348@vauxhall.crustytoothpaste.net","threadId":"38743","inReplyTo":"87d24kzbor.fsf@igel.home","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2015-03-07T22:53:14Z","receivedAt":"2015-03-07T22:53:14Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sat, Mar 07, 2015 at 11:26:28PM +0100, Andreas Schwab wrote:\n>Diego Viola <diego.viola@gmail.com> writes:\n>\n>> I know I could git-init in a empty directory\n>\n>You can also git init a non-empty directory.\n\nI have a script to set up a new throwaway VM with my dotfiles using git.\nIt looks a bit like the following ($BRANCH != master):\n\n  SSH=\"ssh $DEST\"\n  \n  $SSH \"cd; $GIT init\"\n  git push --receive-pack=$GIT-receive-pack $DEST:~/.git $BRANCH\n  $SSH \"\n      $GIT pull . $BRANCH\n      $GIT submodule update --init\n  \"\n\nIt relies on the ability to git init a non-empty directory.  $BRANCH can \nbe master if you use the new updateInstead functionality in git 2.3.0, \nand you can use git pull from a remote location instead of the push/pull \npair if that suits you better.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187\n"},{"id":"257255","messageId":"CA+ToGPHOM9mu_ng4wVc7QUGyvf09y=nDjE32oSh9JzKbpbzN2Q@mail.gmail.com","threadId":"38743","inReplyTo":"87d24kzbor.fsf@igel.home","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"Diego Viola","fromEmail":"diego.viola@gmail.com","sentAt":"2015-03-08T00:02:26Z","receivedAt":"2015-03-08T00:02:26Z","isPatch":false,"sender":{"key":"diego.viola@gmail.com","avatar":null},"body":"Sorry, I wanted to say: I know I can git-clone in a empty directory\nand then move the files over to $HOME.\n\nI know I can git init in a non-empty directory. :-)\n\nThanks,\n\nDiego\n\nOn Sat, Mar 7, 2015 at 7:26 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> Diego Viola <diego.viola@gmail.com> writes:\n>\n>> I know I could git-init in a empty directory\n>\n> You can also git init a non-empty directory.\n>\n> Andreas.\n>\n> --\n> Andreas Schwab, schwab@linux-m68k.org\n> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n> \"And now for something completely different.\"\n"},{"id":"257257","messageId":"CA+ToGPFSbOjfd5gJg+r-7WkwMB=m=4sOupaZo1WUn+O0bxAAXw@mail.gmail.com","threadId":"38743","inReplyTo":"CA+ToGPHOM9mu_ng4wVc7QUGyvf09y=nDjE32oSh9JzKbpbzN2Q@mail.gmail.com","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"Diego Viola","fromEmail":"diego.viola@gmail.com","sentAt":"2015-03-08T01:53:13Z","receivedAt":"2015-03-08T01:53:13Z","isPatch":false,"sender":{"key":"diego.viola@gmail.com","avatar":null},"body":"Something like this is the scenario I'm talking about:\n\n$ mkdir non-empty-dir\n$ cd non-empty-dir\n$ touch foo bar baz\n$ git clone -f url:user/dotfiles.git .\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n    bar\n    baz\n    foo\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\n\nOn Sat, Mar 7, 2015 at 9:02 PM, Diego Viola <diego.viola@gmail.com> wrote:\n> Sorry, I wanted to say: I know I can git-clone in a empty directory\n> and then move the files over to $HOME.\n>\n> I know I can git init in a non-empty directory. :-)\n>\n> Thanks,\n>\n> Diego\n>\n> On Sat, Mar 7, 2015 at 7:26 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n>> Diego Viola <diego.viola@gmail.com> writes:\n>>\n>>> I know I could git-init in a empty directory\n>>\n>> You can also git init a non-empty directory.\n>>\n>> Andreas.\n>>\n>> --\n>> Andreas Schwab, schwab@linux-m68k.org\n>> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n>> \"And now for something completely different.\"\n"},{"id":"257258","messageId":"569EEC82-664C-48A7-990D-BFCDB7D78D16@gmail.com","threadId":"38743","inReplyTo":"CA+ToGPFSbOjfd5gJg+r-7WkwMB=m=4sOupaZo1WUn+O0bxAAXw@mail.gmail.com","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-03-08T02:32:47Z","receivedAt":"2015-03-08T02:32:47Z","isPatch":false,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Mar 7, 2015, at 17:53, Diego Viola wrote:\n> Something like this is the scenario I'm talking about:\n>\n> $ mkdir non-empty-dir\n> $ cd non-empty-dir\n> $ touch foo bar baz\n> $ git clone -f url:user/dotfiles.git .\n> $ git status\n> On branch master\n> Your branch is up-to-date with 'origin/master'.\n> Untracked files:\n>  (use \"git add <file>...\" to include in what will be committed)\n>\n>    bar\n>    baz\n>    foo\n>\n> nothing added to commit but untracked files present (use \"git add\"  \n> to track)\n\nHave you considered using an alias?\n\ngit config --global alias.irfc \\\n   '!sh -c '\\''git init && git remote add origin \"$1\" && git fetch &&  \ngit checkout \"${2:-master}\"'\\'' sh'\n\n(You'll likely have to carefully unwrap that line above.)\n\nThen you get\n\n   git irfc <URL> [<branch>]\n\nwhere <branch> defaults to master.\nSo your scenario would become just:\n\n\n\n$ mkdir non-empty-dir\n$ cd non-empty-dir\n$ touch foo bar baz\n$ git irfc url:user/dotfiles.git\n$ git status\nOn branch master\nYour branch is up-to-date with 'origin/master'.\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n    bar\n    baz\n    foo\n\nnothing added to commit but untracked files present (use \"git add\" to  \ntrack)\n\n\n-Kyle\n\nP.S. irfc = init, remote, fetch, checkout.  But do make up a better  \nname. :)\n"},{"id":"257335","messageId":"CA+ToGPFZ3JUZJJch03Cc=r7oRj_CKaBwMFCnG0y8XGT6RJYZ2A@mail.gmail.com","threadId":"38743","inReplyTo":"569EEC82-664C-48A7-990D-BFCDB7D78D16@gmail.com","subject":"Re: Please consider adding a -f switch to git-clone (or something similar)","fromName":"Diego Viola","fromEmail":"diego.viola@gmail.com","sentAt":"2015-03-08T18:27:01Z","receivedAt":"2015-03-08T18:27:01Z","isPatch":false,"sender":{"key":"diego.viola@gmail.com","avatar":null},"body":"Kyle,\n\nThanks, I suppose that works well enough for my needs. I wasn't aware\nthat aliases were that flexible in git.\n\nI also have no problem to git-init and do all the other steps manually.\n\nThanks,\n\nDiego\n\nOn Sat, Mar 7, 2015 at 11:32 PM, Kyle J. McKay <mackyle@gmail.com> wrote:\n> On Mar 7, 2015, at 17:53, Diego Viola wrote:\n>>\n>> Something like this is the scenario I'm talking about:\n>>\n>> $ mkdir non-empty-dir\n>> $ cd non-empty-dir\n>> $ touch foo bar baz\n>> $ git clone -f url:user/dotfiles.git .\n>> $ git status\n>> On branch master\n>> Your branch is up-to-date with 'origin/master'.\n>> Untracked files:\n>>  (use \"git add <file>...\" to include in what will be committed)\n>>\n>>    bar\n>>    baz\n>>    foo\n>>\n>> nothing added to commit but untracked files present (use \"git add\" to\n>> track)\n>\n>\n> Have you considered using an alias?\n>\n> git config --global alias.irfc \\\n>   '!sh -c '\\''git init && git remote add origin \"$1\" && git fetch && git\n> checkout \"${2:-master}\"'\\'' sh'\n>\n> (You'll likely have to carefully unwrap that line above.)\n>\n> Then you get\n>\n>   git irfc <URL> [<branch>]\n>\n> where <branch> defaults to master.\n> So your scenario would become just:\n>\n>\n>\n> $ mkdir non-empty-dir\n> $ cd non-empty-dir\n> $ touch foo bar baz\n> $ git irfc url:user/dotfiles.git\n> $ git status\n> On branch master\n> Your branch is up-to-date with 'origin/master'.\n> Untracked files:\n>  (use \"git add <file>...\" to include in what will be committed)\n>\n>    bar\n>    baz\n>    foo\n>\n> nothing added to commit but untracked files present (use \"git add\" to track)\n>\n>\n> -Kyle\n>\n> P.S. irfc = init, remote, fetch, checkout.  But do make up a better name. :)\n"}]}