0

I have my personal git repo name myrepo. I have fetched somerepo using git clone and now I want to make it an integral-part of myrepo. I am thinking of doing it as following.

  1. Inside myrepo tree, git clone <somerepo>.
  2. Remove all git-related files and directories from somerepo such as .git .gitignore etc.
  3. Add all files in fetched somerepo and commit.

Is there any command which clones only 'raw' data of a git-repo (ignore git-related files)? Better still, is there a command (or may be more than one) which can do these three steps.

I have read about git submodule a bit. Can submodule be used? Assume that I don't have any interest in future-modification in somerepo.

Dilawar
  • 5,438
  • 9
  • 45
  • 58
  • you can use a submodule, or you can do a subtree merge … both will preserve full history of the "foreign" repository (which is generally what you want) – knittl Apr 01 '12 at 13:51

2 Answers2

1

I may not understand the question, because it sounds like you've already answered it.

After cloning, just rm -fr the .git directory. There's only one .git directory per repository, so it's easy to remove it. (Not like subversion where you have .svn in each directory.)

You said, "assume I don't have any future interest," so there's no need to remove .gitignore files. But if you really wanted to, that's also pretty easy:

$ find <path_to_some_repo> -name '.gitignore' -exec rm {} \;

Finally, git add <path_to_some_repo> and you're done.

If that's not what you're looking for, then please explain your requirements more precisely.

Is there any command which clones only 'raw' data of a git-repo (ignore git-related files)?

Not literally, because "clone" in git means to fetch all of the refs and objects in the repository. There is git checkout-index which is kind of similar to "svn export", but you still have to have a copy of the repository in order to do that.

See: Do a "git export" (like "svn export")?

Community
  • 1
  • 1
Mark E. Haase
  • 25,965
  • 11
  • 66
  • 72
  • I was looking for a single command inside git without going through all of this. Something like `git pull-and-merge-in-tree some-repo` .. – Dilawar Apr 02 '12 at 06:09
0

You can add the second repository as a remote:

git remote add some_repo git@server:some-repo

Issue git pull some_repo or git fetch some_repo + manual merge afterwards.

A subtree merge might be appropiate as well.

Femaref
  • 60,705
  • 7
  • 138
  • 176
  • Preferably you'd do a subtree merge, to move all files into a subtree of the repository – knittl Apr 01 '12 at 13:52
  • @Fermaref If I do `git clone ` on some other machine after doing your steps. Will I fetch some-repo automatically? – Dilawar Apr 01 '12 at 13:54
  • Feel free to propose an edit/detail the commands in a comment I'll approve/add it myself. – Femaref Apr 01 '12 at 13:54
  • @Dilawar: After you merged some-repo into my-repo and pushed it back to the original remote, it (and its history) will be part of my-repo, and with the next pull everybody will get it. – Femaref Apr 01 '12 at 13:55
  • @Femaref in your command `git remote ... git@server:some-repo`, server is server of my-repo or some-repo? – Dilawar Apr 01 '12 at 13:59
  • it's the path to some-repo, the operation is done in my-repo. Make sure you have no working tree changes though. – Femaref Apr 01 '12 at 14:05