Thread (5 messages) 5 messages, 3 authors, 2016-06-15

Re: Cloning into an existing directory

flat view

From: Brent Goodrick <hidden>
Date: 2016-06-15 22:46:12

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
[off-list ref] wrote:
On 2/16/09, Brent Goodrick [off-list ref] wrote:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help