medev21
medev21

Reputation: 3051

moving a git folder from local computer to an existing repo - commit history included

I'm trying to move a folder (let's call it "projectA") I've started with git version control in local computer- it has not repo connected

I would like to move "projectA" along with its history commit to a new repo called projectB.

projectA - this is stored in local computer and has no github repo
  app

projectB
  folder1
  folder2
  projectA - 'final destination'

So far I understand I have to do git clone for projectB, but after that I don't know to transfer projectA with its history commit under ProjectB.

Can anybody help me with this? I only know the basics of git - add commit pull push. Your help will be appreciated.

Upvotes: 0

Views: 46

Answers (1)

Falloutcoder
Falloutcoder

Reputation: 1011

In your Project A create a new branch

git checkout -b project_a_work

Add remote github repo for Project B

git remote add origin [email protected]/project_b.git

Do a git fetch and checkout project B master(any other branch you want to merge on)

git fetch
git checkout origin/master

Now merge the Project A work on Project B's current checkout branch

git merge project_a_work

OR

If you want all Project A history to be written after last commit on Project B, you can do git rebase

git rebase project_a_work

Upvotes: 1

Related Questions