-1

I want to get all github commit history from another repository to my new github repository.

Scenario:

That repository could be:

  • From my another repository
  • From contributed projects such as my company project
  • From forked project which one is in private mode

In my case, I worked on my company project. Which repository is in private mode on github. Now I want all code base from that repository with git commit. Though I can clone that project and upload it new repository without commit history but I want also commit history. Does it possible?

iamtheasad
  • 1,017
  • 13
  • 15
  • 2
    I dont understand - cant you just press fork on gitlab? – Casper Bang Aug 10 '22 at 09:02
  • 2
    what have you tried so far ? – LeGEC Aug 10 '22 at 09:13
  • 2
    You add a remote to your local repo that points to the new repo in github, then push any branch into the new remote. – eftshift0 Aug 10 '22 at 09:22
  • @CasperBang I updated question. I worked on my company project. Which repository is in private mode on github. Now I want all code base from that repository with git commit. Though I can clone that project and upload it new repository without commit history but I want also commit history. Does it possible? – iamtheasad Aug 10 '22 at 10:43
  • @LeGEC I updated question. I worked on my company project. Which repository is in private mode on github. Now I want all code base from that repository with git commit. Though I can clone that project and upload it new repository without commit history but I want also commit history. Does it possible? – iamtheasad Aug 10 '22 at 10:46
  • @eftshift0 I worked on my company project. Which repository is in private mode on github. Now I want all code base from that repository with git commit. Though I can clone that project and upload it new repository without commit history but I want also commit history. Does it possible? – iamtheasad Aug 10 '22 at 10:47
  • 2
    Does this answer your question? [Combining multiple git repositories](https://stackoverflow.com/questions/277029/combining-multiple-git-repositories) – tymtam Aug 10 '22 at 11:05
  • 2
    If you can _clone_ it (which implies you get history along with it), you can push branches (and their histories, like any other push) into a different _remote_. – eftshift0 Aug 10 '22 at 11:06
  • 2
    @iamtheasad : A commit always comes with its complete history : it contains a link to its parent, which in turn contains a link to its parent, etc ... when you push a branch or a commit, you also push its history with it – LeGEC Aug 10 '22 at 12:05

1 Answers1

2

Your assumption is wrong.

Though I can clone that project and upload it new repository without commit history

A normal clone of a repository contains the full history.

Please not that making a public fork/clone of a private repository seems to go against the wishes of the owner of the original repository and it may be illegal

tymtam
  • 31,798
  • 8
  • 86
  • 126
  • I think you know that from another repositorie's .git file won't support in new repository. So deleted the old .git file and uploaded it new new github repository. Hope I am clear?! – iamtheasad Aug 10 '22 at 10:51
  • 3
    Deleting .git **folder** makes the folder stop being a git repository. Why did you delete it? That's where the history is. – tymtam Aug 10 '22 at 10:54
  • On my new repository already have a .git folder so I deleted old one. I want new repository's .git folder to merge with the old .git repository. – iamtheasad Aug 10 '22 at 10:59
  • 2
    In this case follow https://stackoverflow.com/questions/277029/combining-multiple-git-repositories – tymtam Aug 10 '22 at 11:05
  • 1
    Thank you for your awareness. But it's completely ok in my company policy. – iamtheasad Aug 10 '22 at 12:24