0

I have a git repository and now I need to add client and server folders to it. i.e. put all the Ionic related things to the client folder and nodeJs related things to the server folder. I have done it like so:

enter image description here

I already have a git repo on git without this folder structure. i.e. basic Ionic 4 app's git repo So how can I create this kind of structure and push it to the same repo?

I have tried this. But it gives below error. I have tried to git pull also but no luck yet.

    git push --set-upstream origin master To https://gitlab.com/my-repo/client.git  ! [rejected]        
master -> master (non-fast-forward) error: failed to push some refs to 'https://gitlab.com/my-
repo/client.git' hint: Updates were rejected because the tip of your current branch is behind hint: its 
remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: 
See the 'Note about fast-forwards' in 'git push --help' for details.

Note: Actually my local branch is up to date with the remote master. I have done it before creating the above folder structure.

Sampath
  • 63,341
  • 64
  • 307
  • 441

1 Answers1

0

When you do git pull, it sees a lot of unrelated histories and refuses to merge and pull the code from the remote branch, as you see in the error stack, try using:

git pull origin master --allow-unrelated-histories

From https://github.com/NishuGoel/ExampleStackOverFlow
 * branch            master     -> FETCH_HEAD
CONFLICT (add/add): Merge conflict in README.md
Auto-merging README.md
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging .gitignore
Automatic merge failed; fix conflicts and then commit the result.

This brings in the unrelated changes, after which you can merge the changes by manually resolving the conflicts that you see in your editor. (Source Control in VS Code on the left.)

Finally commit, and push the result.

Hope this helps!

Nishu Goel
  • 11
  • 4