git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Please consider adding a -f switch to git-clone (or something similar)

From
DVDiego Viola <diego.viola@gmail.com>
Date
Mar 8, 2015, 18:27 UTC
Message-ID
<CA+ToGPFZ3JUZJJch03Cc=r7oRj_CKaBwMFCnG0y8XGT6RJYZ2A@mail.gmail.com>
In-Reply-To
<569EEC82-664C-48A7-990D-BFCDB7D78D16@gmail.com>
Kyle,

Thanks, I suppose that works well enough for my needs. I wasn't aware that aliases were that flexible in git.

I also have no problem to git-init and do all the other steps manually.
Thanks,
Diego
On Sat, Mar 7, 2015 at 11:32 PM, Kyle J. McKay <mackyle@gmail.com> wrote:
Show 59 quoted lines
> On Mar 7, 2015, at 17:53, Diego Viola wrote:
>>
>> Something like this is the scenario I'm talking about:
>>
>> $ mkdir non-empty-dir
>> $ cd non-empty-dir
>> $ touch foo bar baz
>> $ git clone -f url:user/dotfiles.git .
>> $ git status
>> On branch master
>> Your branch is up-to-date with 'origin/master'.
>> Untracked files:
>>  (use "git add <file>..." to include in what will be committed)
>>
>>    bar
>>    baz
>>    foo
>>
>> nothing added to commit but untracked files present (use "git add" to
>> track)
>
>
> Have you considered using an alias?
>
> git config --global alias.irfc \
>   '!sh -c '\''git init && git remote add origin "$1" && git fetch && git
> checkout "${2:-master}"'\'' sh'
>
> (You'll likely have to carefully unwrap that line above.)
>
> Then you get
>
>   git irfc <URL> [<branch>]
>
> where <branch> defaults to master.
> So your scenario would become just:
>
>
>
> $ mkdir non-empty-dir
> $ cd non-empty-dir
> $ touch foo bar baz
> $ git irfc url:user/dotfiles.git
> $ git status
> On branch master
> Your branch is up-to-date with 'origin/master'.
> Untracked files:
>  (use "git add <file>..." to include in what will be committed)
>
>    bar
>    baz
>    foo
>
> nothing added to commit but untracked files present (use "git add" to track)
>
>
> -Kyle
>
> P.S. irfc = init, remote, fetch, checkout.  But do make up a better name. :)
Previous: Kyle J. McKay
Message 7 of 7 in “Please consider adding a -f switch to git-clone (or something similar)”
  1. Diego ViolaMar 7, 2015
  2. Andreas SchwabMar 7, 2015
  3. brian m. carlsonMar 7, 2015
  4. Diego ViolaMar 8, 2015
  5. Diego ViolaMar 8, 2015
  6. Kyle J. McKayMar 8, 2015
  7. Diego ViolaMar 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.