Re: Cloning into an existing directory
- From
Brent Goodrick <bgoodr@gmail.com>
- Date
- Feb 16, 2009, 16:13 UTC
- Message-ID
- <e38bce640902160813u2771d55co3eb583a0922c09c5@mail.gmail.com>
- In-Reply-To
- <c1b8b6670902152331p9bbdb8fo7bf7048039b5301c@mail.gmail.com>
Thanks very much for the advice, Russell.
I did a test by creating the small repo with one file in it, .bashrc and got to the point of the git-fetch. That git-fetch did not complain about the pre-existing .bashrc file. Should it, or is the design of git-fetch to alter the state inside the .git area only and not the working tree? The scan of the user manual and the git-fetch man page does not seem to clarify the effect (none?) that git-fetch has on the working tree.
Now, I see that you said it would complain upon checkout, which it did:
$ git checkout master error: Untracked working tree file '.bashrc' would be overwritten by merge.
Fair enough: git is doing the right thing here and not overwriting the target file since it is not yet git-controlled. Given that I may have many files, my naive way of fixing that is to
1. Move aside each file it complains about 2. Run the git-checkout command again 3. Move each file back to their original names, thus creating a local edit w.r.t. git 4. Run git diff to see those changes, making additional edits 5. Finally, check in the result
To side-step writing my own wrapper script around git, is there a command-line option to do steps 1 through 3, but not 4 and 5?
Thanks again for your help, bg
On Sun, Feb 15, 2009 at 11:31 PM, Russell Steicke <russellsteicke@gmail.com> wrote:
Show 30 quoted lines
> On 2/16/09, Brent Goodrick <bgoodr@gmail.com> wrote: >> Hi, >> >> I would like to manage my startup scripts such as .bashrc and other >> setup files relative to my HOME directory using Git. However, >> git-clone disallows cloning into the existing "." directory, but only >> allows cloning into a subdirectory that does not yet exist. If my >> home directory is /home/brentg and my remote repository is on >> remote_machine:~brentg/my_setup.git then git clone in my home >> directory on the local machine creates /home/brentg/my_setup with >> files such as .bashrc inside it, which is not what I want. I want them >> checked out and managed _in_ the current working directory, and not to >> mess with other files or directories that already exist that are never >> to be managed by git. > > cd > git init > git remote add origin remote_machine:~brentg/my_setup.git > git fetch > git branch master origin/master > git checkout master > > You may have to delete .bashrc and others before git will overwrite > them on checkout. > > > > -- > Virus found in this message. >