Re: move git repository out of a folder?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Shawn O. Pearce" <spearce@xxxxxxxxxxx> writes:

> Sean Brown <seanmichaelbrown@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux