* Cloning into an existing directory
@ 2009-02-16 7:10 Brent Goodrick
2009-02-16 7:31 ` Russell Steicke
0 siblings, 1 reply; 5+ messages in thread
From: Brent Goodrick @ 2009-02-16 7:10 UTC (permalink / raw)
To: git
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.
I don't want to create softlinks from files in the HOME directory down
into the subdirectory (e.g., /home/brentg/.bashrc -->
my_setup/.bashrc) if I can at all avoid it, since then to do so for
all of my setup would require extra scripting work, and it may be the
case that some setup files are required to be regular files and not
symbolic links by certain programs. Moving the files manually is also
out of the question, since then I can't do a git diff operation on the
file directly.
I did see the --bare option to clone, but the entry in the git-clone
man page implies that using that option turns off a lot of tracking of
things that I believe I will need:
--bare
Make a bare GIT repository. That is, instead of creating
<directory> and placing the administrative files in
<directory>/.git, make the <directory> itself the $GIT_DIR.
This obviously implies the -n because there is nowhere to check
out the working tree. Also the branch heads at the remote
are copied directly to corresponding local branch heads, without
mapping them to refs/remotes/origin/. When this option is
used, neither remote-tracking branches nor the related
configuration variables are created.
Specifically, the statement: "branch heads at the remote are copied
directly to corresponding local branch heads, without mapping them to
refs/remotes/origin" and "neither remote-tracking branches nor the
related configuration variables are created" are what is scaring me
off.
Is there a way do to this, or is the --bare option really what I need
here? If so, what are the caveats of the use of that option given the
above "scary" statements.
What is interesting to note, is that git clone on a local repository
to "." seems to work just fine. It is only when cloning from remote
repositories that it complains about the target being an existing
directory.
Thanks,
bg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cloning into an existing directory
2009-02-16 7:10 Cloning into an existing directory Brent Goodrick
@ 2009-02-16 7:31 ` Russell Steicke
2009-02-16 16:13 ` Brent Goodrick
0 siblings, 1 reply; 5+ messages in thread
From: Russell Steicke @ 2009-02-16 7:31 UTC (permalink / raw)
To: Brent Goodrick; +Cc: git
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cloning into an existing directory
2009-02-16 7:31 ` Russell Steicke
@ 2009-02-16 16:13 ` Brent Goodrick
2009-02-16 16:48 ` Andrew Ruder
0 siblings, 1 reply; 5+ messages in thread
From: Brent Goodrick @ 2009-02-16 16:13 UTC (permalink / raw)
To: Russell Steicke; +Cc: git
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:
> 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.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cloning into an existing directory
2009-02-16 16:13 ` Brent Goodrick
@ 2009-02-16 16:48 ` Andrew Ruder
2009-02-17 2:53 ` Brent Goodrick
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Ruder @ 2009-02-16 16:48 UTC (permalink / raw)
To: Brent Goodrick; +Cc: git
On Mon, Feb 16, 2009 at 9:13 AM, Brent Goodrick <bgoodr@gmail.com> wrote:
> 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
Actually, on my git (1.6.0.4) this just magically works due to the
fact that 'git init' sets up the repository with HEAD pointing to
refs/heads/master (which doesn't exist yet) and you go ahead and
create the master branch with the 'git branch' command.
In other words, in this particular situation the 'git checkout'
command is completely unnecessary and if you just run a 'git status'
you should already see that git sees all the differences already as
local edits (assuming you didn't call you branch in the 'git branch'
step something other than master).
--
Andrew Ruder <andy@aeruder.net>
http://www.aeruder.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Cloning into an existing directory
2009-02-16 16:48 ` Andrew Ruder
@ 2009-02-17 2:53 ` Brent Goodrick
0 siblings, 0 replies; 5+ messages in thread
From: Brent Goodrick @ 2009-02-17 2:53 UTC (permalink / raw)
To: Andrew Ruder; +Cc: git
On Mon, Feb 16, 2009 at 8:48 AM, Andrew Ruder <andy@aeruder.net> wrote:
>
> On Mon, Feb 16, 2009 at 9:13 AM, Brent Goodrick <bgoodr@gmail.com> wrote:
> > 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
>
> Actually, on my git (1.6.0.4) this just magically works due to the
> fact that 'git init' sets up the repository with HEAD pointing to
> refs/heads/master (which doesn't exist yet) and you go ahead and
> create the master branch with the 'git branch' command.
>
> In other words, in this particular situation the 'git checkout'
> command is completely unnecessary and if you just run a 'git status'
> you should already see that git sees all the differences already as
> local edits (assuming you didn't call you branch in the 'git branch'
> step something other than master).
Well, it does show them as local edits, and actually shows the file as
deleted. I ended up having to do a git-add on those files and commit
them, which will work for me.
bg
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-17 2:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-16 7:10 Cloning into an existing directory Brent Goodrick
2009-02-16 7:31 ` Russell Steicke
2009-02-16 16:13 ` Brent Goodrick
2009-02-16 16:48 ` Andrew Ruder
2009-02-17 2:53 ` Brent Goodrick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).