* move git repository out of a folder?
@ 2008-06-04 20:03 Sean Brown
2008-06-04 20:07 ` Shawn O. Pearce
2008-06-04 20:08 ` Avery Pennarun
0 siblings, 2 replies; 5+ messages in thread
From: Sean Brown @ 2008-06-04 20:03 UTC (permalink / raw)
To: git
Let's say I've got this directory structure of source files:
/folderA
/folderA/sourcecode/
/folderA/sourcecode/file1.txt
/folderA/sourcecode/file2.txt
etc...
When putting the project under git source control, I did this:
cd /folderA
git init
So now when colleagues clone my repository, they get the source code
in the "sourcecode" folder. I'd like to just make the repository
simply give them the source files, not in a directory. In other
words, as if I had originally been smart and done this:
cd /folderA/sourcecode
git init
Can I make that happen without losing all of the history?
Thanks,
Sean
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: move git repository out of a folder?
2008-06-04 20:03 move git repository out of a folder? Sean Brown
@ 2008-06-04 20:07 ` Shawn O. Pearce
2008-06-04 20:14 ` Jakub Narebski
2008-06-04 20:08 ` Avery Pennarun
1 sibling, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2008-06-04 20:07 UTC (permalink / raw)
To: Sean Brown; +Cc: git
Sean Brown <seanmichaelbrown@gmail.com> wrote:
> Let's say I've got this directory structure of source files:
>
> /folderA
> /folderA/sourcecode/
> /folderA/sourcecode/file1.txt
> /folderA/sourcecode/file2.txt
> etc...
>
> When putting the project under git source control, I did this:
>
> cd /folderA
> git init
>
> So now when colleagues clone my repository, they get the source code
> in the "sourcecode" folder. I'd like to just make the repository
> simply give them the source files, not in a directory. In other
> words, as if I had originally been smart and done this:
>
> cd /folderA/sourcecode
> git init
>
> Can I make that happen without losing all of the history?
git mv sourcecode/* .
rmdir sourcecode
git commit
--
Shawn.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: move git repository out of a folder?
2008-06-04 20:03 move git repository out of a folder? Sean Brown
2008-06-04 20:07 ` Shawn O. Pearce
@ 2008-06-04 20:08 ` Avery Pennarun
1 sibling, 0 replies; 5+ messages in thread
From: Avery Pennarun @ 2008-06-04 20:08 UTC (permalink / raw)
To: seanmichaelbrown; +Cc: git
On 6/4/08, Sean Brown <seanmichaelbrown@gmail.com> wrote:
> So now when colleagues clone my repository, they get the source code
> in the "sourcecode" folder. I'd like to just make the repository
> simply give them the source files, not in a directory. In other
> words, as if I had originally been smart and done this:
>
> cd /folderA/sourcecode
> git init
>
> Can I make that happen without losing all of the history?
You could just make a commit which renames all the files into the
parent folder. This is relatively harmless and correctly reflects
what really happened.
You might also want to look at git-filter-branch and its
"--subdirectory-filter" option.
Have fun,
Avery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: move git repository out of a folder?
2008-06-04 20:07 ` Shawn O. Pearce
@ 2008-06-04 20:14 ` Jakub Narebski
2008-06-04 20:18 ` Sean Brown
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2008-06-04 20:14 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Sean Brown, git
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Sean Brown <seanmichaelbrown@gmail.com> wrote:
> >
> > Let's say I've got this directory structure of source files:
> >
> > /folderA
> > /folderA/sourcecode/
> > /folderA/sourcecode/file1.txt
> > /folderA/sourcecode/file2.txt
> > etc...
> >
> > When putting the project under git source control, I did this:
> >
> > cd /folderA
> > git init
> >
> > So now when colleagues clone my repository, they get the source code
> > in the "sourcecode" folder. I'd like to just make the repository
> > simply give them the source files, not in a directory. In other
> > words, as if I had originally been smart and done this:
> >
> > cd /folderA/sourcecode
> > git init
> >
> > Can I make that happen without losing all of the history?
>
> git mv sourcecode/* .
> rmdir sourcecode
> git commit
What he said. Git should automatically detect renames. When pulling
code from someone who hasn't made this change yet, you might need to
use 'subtree' merge strategy, as currently git would put files added
as sourcecode/filename in sourcecode/filename, not as top dir filename
when pulling from side branch.
If you want to _change history_, as if you made correct decision at
the start (and convince everyone to reclone, or to do the same
surgery; or if you for the time being are solo contributor to the
project), you can use git-filter-branch (formerly cg-admin-rewrite-hist ;-).
HTH
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: move git repository out of a folder?
2008-06-04 20:14 ` Jakub Narebski
@ 2008-06-04 20:18 ` Sean Brown
0 siblings, 0 replies; 5+ messages in thread
From: Sean Brown @ 2008-06-04 20:18 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Shawn O. Pearce, git
On Wed, Jun 4, 2008 at 4:14 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
>> Sean Brown <seanmichaelbrown@gmail.com> wrote:
>> >
>> > Let's say I've got this directory structure of source files:
>> >
>> > /folderA
>> > /folderA/sourcecode/
>> > /folderA/sourcecode/file1.txt
>> > /folderA/sourcecode/file2.txt
>> > etc...
>> >
>> > When putting the project under git source control, I did this:
>> >
>> > cd /folderA
>> > git init
>> >
>> > So now when colleagues clone my repository, they get the source code
>> > in the "sourcecode" folder. I'd like to just make the repository
>> > simply give them the source files, not in a directory. In other
>> > words, as if I had originally been smart and done this:
>> >
>> > cd /folderA/sourcecode
>> > git init
>> >
>> > Can I make that happen without losing all of the history?
>>
>> git mv sourcecode/* .
>> rmdir sourcecode
>> git commit
>
> What he said. Git should automatically detect renames. When pulling
> code from someone who hasn't made this change yet, you might need to
> use 'subtree' merge strategy, as currently git would put files added
> as sourcecode/filename in sourcecode/filename, not as top dir filename
> when pulling from side branch.
>
> If you want to _change history_, as if you made correct decision at
> the start (and convince everyone to reclone, or to do the same
> surgery; or if you for the time being are solo contributor to the
> project), you can use git-filter-branch (formerly cg-admin-rewrite-hist ;-).
>
Thank you Shawn and Jakub. This worked perfectly.
Sean
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-04 20:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04 20:03 move git repository out of a folder? Sean Brown
2008-06-04 20:07 ` Shawn O. Pearce
2008-06-04 20:14 ` Jakub Narebski
2008-06-04 20:18 ` Sean Brown
2008-06-04 20:08 ` Avery Pennarun
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).