1

I'll try to be as succinct as possible:

** background **
I started a project for a non-profit org with some friends a couple months ago; as we are not charging anything, a couple of friends abandoned ship (understandably enough as they are really busy at their actual jobs). However, those guys were in charge to develop front end of the project.

I took over of the front-end (initially thought with vuejs, I used vuejs + quasar framework).

In the initial repository (gitlab), front-end (vue) and back-end (django + postgres) were included in different directories under the same repo (I am a newbie so I dont know if this is good practice or not, with this I mean there is a repo in gitlab with a /backend directory and a /frontend firectory, each containing the respectively code).

I wasn't sure If they were coming back or not so I developed in my own device and pushed to my own github. In the end, they didn't come back and I finished the mock up's so now I want to push to gitlab in order to continue with the project.

** the goal **
I want replace the existing code under the repository's "/frontend" directory with my own code (as stated, there is also a "/backend" directory which contains the django code and off course, should'nt be removed).

** what I have researched **
As I have researched, I have found the following options

  1. mirror the new code into the old project. I found one article explaining how I can use the --mirror flag to copy my code to the project:

cd my/own/repo/path
git push --mirror gitlabs/old/repo

THE ISSUE: I think this will overwrite the backend development and only keep my FE code.

  1. add the new code as a submodule of the initial project

cd initial/project/
git submodule add frontendDirectory
git commit -m "Added the FE submodule to the project."
git push

THE ISSUE: Although I think this is the way to go, I am having the following doubts:

a) will it erase all previous code in the frontEndDirectory or should I manually erase it beforehand? (I mean, I could easily remove it using rm -r initial/project/frontendDir/ but I dont know if this is good practice or git has a built-in option).
b) the intial repo had both FE and BE together and now I partitioned them (FE specifically); although I'd think this is the best practice I don't feel competent enough to impose it (now BE will have to "git submodule update --init --recursive" if they want to pull the FE, as I understand).
c) I'd have to manually update the FE submodule every time and have to keep working on the github repository instead of merging everything to the gitlab repo.

  1. Manually removing old FE code and copying new code.

Nothing would seem simpler as erasing old code with "rm -r" and copying the new one with "cp -r", and the pushing to gitlab, yet I have the following questions:

a) how would I initialize my quasar/vue project in the old repo? will the copy be enough as I am getting everything from the already initialize quasar/vue project? or should I initialize a quasar/vue project in the destination (old repo's FE dir) folder first and then import (copy) everything?
b) I will lose all the commits (I feel confy with my current code but still I think it'd be nice to keep the old commits).
c) This feels like cheating and that there should be a built-in git option for easily, locally copying everything from one project to another

I think this issue might be rather outdated and/or trivial, still would appreciate any input or recommended lectures as the ones I found don't seem to fully answer my questions.

Thanks in advance and cheers.

  • Maybe this would help: https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories What you need is to add the repository as a new branch and then merge that branch into master. – Newerth Dec 08 '20 at 05:20

1 Answers1

0

There are two possible actions that I would like to recommend and these are;

  1. Considering that you have developed a whole entire different application on (GitHub) that has both the FE and BE in one directory. It will be much better to create a new repo for this work in case you want to just move your changes from GitHub to GitLab and to do this all you have to do is
 - Head over to Gitlab and create a new repository
 - Then you can either download the source code zip from `Github` or probably use the local copy and change the remote origin for your project

 $ cd within the project directory
 $ git remote add origin https://gitlab.com/user/repo.git
 # Set a new remote

 $ git remote -v
 # Verify new remote
 > origin  https://gitlab.com/user/repo.git (fetch)
 > origin  https://gitlab.com/user/repo.git (push)
 $ git push 
  1. Alternatively if you do not want to create another Repo you can split the files into what you need to run FE (Vue.js files, I believe) and what you need for the BE (Django)
 - Clone the respective `repos` from `Gitlab`
 $ git clone git@github.com:UserName/gitRepositories.git
 $ cd into the repo
 - create a new branch for these changes that you want to be added
 then push the branch and head over to `GitLab` and create a merge request using the create merge request button that will be showing up on top of your new branch on the `GitLab` website
- Now head over to the main branch on `GitLab` still and click the merge button assuming you have the permissions to do so
Repeat the same procedure for the `BE` as well

What this will do is to allow you to keep the current state of your GitLab repos as a previous state such that in the event that your teammates come back and they do not agree with your changes you can always revert back to what the project repo changes were before you made changes to it.

nuwe1
  • 61
  • 7