💾 Archived View for perso.pw › blog › articles › git-merge-noob.gmi captured on 2023-04-26 at 13:59:04. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

➡️ Next capture (2023-05-24)

-=-=-=-=-=-=-

How to merge changes with git when you are a noob

NIL=> Comment on Mastodon

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

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 !