Git. How to add external repository to your project




If you work with external developers and you often have to get the code from them, it's not very good to transfer it with dropbox or something like that. You want to achieve it, view changes, make tests and build it. It's why CI/CD is made for. At first you should add external repository to your project and to automate the process of getting new builds. Here's how to do it.

Step 1. Clone the existing git. If it already exists, skip this step and make step 2
git clone https://gitlab.com/test_poject_4/myproject.git

Step 2. Go to the projectdirectory
cd ./myproject

Step 3. Add remote repository and name it.
git remote add out https://github.com/heroku/12factor
In this example the remote repository is called 'out'

Step 4. Receive all the commits from the remote repository
git fetch out

Step 5. In your reposiriy you should create the special fork for external repository. If you work with external developers, you can call it 'developer' and set with wich remote branch it should be connected.
git branch developer out/master

Step 6. Switch to the brach you have just created
git checkout developer

Step 7. Check if you branch is up to date or update it
git pull

Step 8. Add the code from external developers (repository) to the corresponding branch
git push -u origin -o merge_request.create

The key "-o merge_request.create" is to create the merge request in Git

You can also create a script to automate the updating of the developer branch from external repository. The code is like this:
cd ./myproject
git checkout developer
git pull
git push -u origin -o merge_request.create

It you use Windows, you can make '.bet' file and add it to the task scheduler. It you use Linux, create '.sh' file and add it to crontab.




No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





MarkiMarta.com. Notes of web-specialist
Since 2009
18+