About how to put the open source project into your own git warehouse (fork) and synchronize the update of the open source version

1. Fork the open source code to your own github library

After a whole afternoon of synchronization, it was impossible to update the version of the downloaded open source project code and the open source project. It turns out that git will compare the commit records when updating. There will be no problems when the same submission records are synchronized, otherwise all the codes will be merged one by one.

So to synchronize the git submission records of open source code to your own project, this uses fork. Fork is to copy the open source code intact, including the git submission records of the open source project. If you don’t use github’s fork to copy here, but download the code yourself to create a new library for copying, there will be big problems when synchronizing the version of the open source project later.

It is very simple to operate after understanding the function of fork. Click the fork button in the upper right corner of the open source project and select create a new fork to copy the fork to your own github repository.

2. Pull the fork project in your own github to the local

Directly pull the code in your own github library in the local idea, or directly use git bash to clone to the local. The detailed steps are not introduced here.

3. Remote open source code to your own project

In order to get the update of the fork source warehouse, now add the address of the fork source warehouse, for example:

$ git remote add upstream [email protected]:Eugene-Tsui/RuoYi-Cloud-EugeneTsui.git

The name of upstream here can be modified, representing the alias of the fork source warehouse. The git address behind is the source warehouse address of your fork.

With the git remote -v command, you can see that there are several remote warehouse addresses associated with the local

The above settings are completed. When you want to update the fork source warehouse, first fetch a copy of the source warehouse to change to the local, and a branch upstream/master will be generated.

$ git fetch upstream

You can view all branches with the view branch command:

$ git branch

If you are not in the local branch master, you need to switch to the local master branch first:

$ git checkout master

Merge changes from the upstream/master branch to the local master branch:

$ git merge upstream/master

Now we have completed the version update of the local code synchronization open source project version, and then pushed it to the github library of our own fork.

4. Matters needing attention

  1. When performing a merge, you must not have uncommitted or unpush code locally, otherwise there will be major problems after the merge.

  1. If there is a problem with the code after the merge while ensuring the first one, you can use the git merge --abort command to go back to before the merge. Similarly, at any time when there is a problem with merge or rebase, you can use git merge --abort or git rebase --abort to return to the state before the merged code.

Guess you like

Origin blog.csdn.net/qq_38786110/article/details/129427330