Title: How to merge changes with git when you are a noob | |
Author: Solène | |
Date: 13 December 2017 | |
Tags: git versioning | |
Description: | |
I'm very noob with **git** and I always screw everything when someone | |
clone one of my repo, contributes and asks me to merge the changes. | |
Now I found an easy way to merge commits from another repository. Here | |
is a simple way to handle this. We will get changes from | |
**project1_modified** to merge it into our **project1** | |
repository. This is not the fastest way or maybe not the optimal way, | |
but I found it to work reliabily. | |
$ cd /path/to/projects | |
$ git clone git://remote/project1_modified | |
$ cd my_project1 | |
$ git checkout master | |
$ git remote add modified ../project1_modified/ | |
$ git remote update | |
$ git checkout -b new_code | |
$ git merge modified/master | |
$ git checkout master | |
$ git merge new_code | |
$ git branch -d new_code | |
This process will makes you download the repository of the people who | |
contributed to the code, then you add it as a remote sources into your | |
project, you create a new branch where you will do the merge, if | |
something is wrong you will be able to manage conflicts easily. Once | |
you tried the code and you are fine, you need to merge this branch to | |
master and then, when you are done, you can delete the branch. | |
If later you need to get new commits from the other repo, it become | |
easier. | |
$ cd /path/to/projects | |
$ cd project1_modified | |
$ git pull | |
$ cd ../my_project1 | |
$ git pull modified | |
$ git merge modified/master | |
And you are done ! |