Pepster K.
Pepster K.

Reputation: 349

merging code outside of git into an existing git project

I have an existing git project, let's call it BobCrane. This needed to completely re-work this project's extensive directory structure.

I created the needed directory structure on the filesystem, outside of any git project. I then manually copied each file from the cloned BobCrane repo into this new directory structure. So the new directories are filled with old files; there are only one or two new ones that didn't exist before.

How can I add/commit/push this new structure to the existing git repo? Is this related to "rebasing"?

Upvotes: 2

Views: 1501

Answers (1)

Oleksandr Horobets
Oleksandr Horobets

Reputation: 1375

  1. init a git repository at new directory structure
    git init
  1. commit all files
    git add -A
    git commit -m "commit message"
  1. add your existing repository remote
    git remote add origin your_existing_repository@url


Merge approach

  1. pull changes from remote
    git pull origin remote_branch_name
  1. after resolving all conflicts execute
    git add -A
    git merge --continue


Rebase approach

  1. Fetch changes from remote
    git fetch

5.1. Rebase onto remote branch

    git rebase origin/remote_branch_name   

5.2. Resolve conflicts if any and execute

    git add -A
    git rebase --continue


6. push new commits into your existing repository

    git push -u origin remote_branch_name


Rebase is preferred way because it will produce cleaner commits history

Upvotes: 4

Related Questions