Hi, I’m Qiufeng. Recently, a lot of open source projects have brought politics into what should be a pure place. Things like Node and React are super star projects.
At present, React issues have fallen, everyone is against a place that was originally pure, why there is politics?
If open source projects are political, I don’t know if Github is far behind. In order to avoid unnecessary losses, I synchronized all my projects on Github to Gitee overnight and wrote this guide.
So I also recommend that you take precautions and backup your Github account, whatever it is, so that you don’t lose your rights.
Synchronization is mainly divided into two parts: existing warehouse synchronization and future code synchronization.
Existing warehouse synchronization
This step is already integrated with the one-click import function on gitee’s official website.
Details: gitee.com/help/articl…
There are three steps:
1. Find the import repository from Github/Gitlab from +
2. Grant permission to Gitee Github
3. After authorization, you can see such a TAB page option. We choose to import all warehouses of the current page
Gitee will automatically import github projects for us, just wait some time.
Once the import is complete, all projects are private, so you don’t have to worry about leaking your own private repository permissions on Gihtub.
Future code synchronization
Although we have all synchronized our existing repositories to Gitee, the source of our local repository is still Github, so we need to deal with this part of the future increment code.
Solution 1: Add remote sources
This scheme is actually very simple, many students in the submission of open source projects, want to incorporate the latest code of open source projects must have used.
git remote add <name> <url>
There are two steps:
1. Add remote repositories under your original Github repository
For example, git remote add gitee ‘ ‘[[email protected]](mailto:[email protected])’ ‘:hua1995116/mmt.git
After adding, you can see something like this:
2. Commit the current increment code
Git push origin // commit to github git push giteeCopy the code
One disadvantage of this approach is that it requires two submissions.
Scheme 2: Add push sources
1. Delete the Gitee source for method 1 (ignore this step if there is no action plan 1 yet)
git remote rm gitee
Copy the code
2. Add the push source
git remote set-url --add origin [email protected]:hua1995116/mmt.git
Copy the code
3. Submit code
git push origin
Copy the code
To save the second step, I have configured a script that can be added quickly. (Provided your Gihtub account name is the same as gitee’s)
NPM I - g MMT MMT import HTTP: / / https://gitee.com/hua1995116/mmt-practices/raw/master/mmt-export-gitee.json / / into the directory you want to add order MMT Run gitee // Every existing Github repository mindlessly runs this commandCopy the code
Effect:
Solution 3: Use github Action
This scheme consists of two steps
1. Create the. Github /workflows directory in the root directory of the repository
2. Create gitee – sync. Yml
Name: Github -sync on: Push: Branches: -master Jobs: repo-sync: env: dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} dst_token: ${{ secrets.GITEE_TOKEN }} gitee_user: ${{ secrets.GITEE_USER }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: persist-credentials: false - name: sync github -> gitee uses: Yikun/hub-mirror-action@master if: Env.dst_token && env.gitee_user with: # Mandatory. Github user (source) SRC: 'github/${{github. Repository_owner}}' 'gitee / ${{secrets. GITEE_USER}}' # will choose, gitee corresponding private key, public key https://gitee.com/profile/sshkeys dst_key: # ${{secrets. GITEE_PRIVATE_KEY}} will choose, Gitee token is used to create warehouse, https://gitee.com/profile/personal_access_tokens dst_token: ${{secretsecrets.GITEE_TOKEN}} ${{secretsecrets.GITEE_TOKEN}} ${{lot. Event. The repository. The name}} # and black and white list, list of static mechanism, can be used to update some specified library # static_list: 'repo_name, repo_name2 # black_list: 'repo_name,repo_name2' # white_list: 'repo_name,repo_name2'Copy the code
3. Add 3 secrets to Github repository: (Setting -> secrets -> New repository secret)
- GITEE_USER, for example, my gitee
hua1995116
GITEE_PRIVATE_KEY
, obtain method (if existing, directly set) -Gitee Private key corresponding to the public key- Create a private key method:
- Generating an SSH Public Key
- Add the SSH public key to the Gitee public key
- Add public keys to Github project secrets;
GITEE_TOKEN
, obtain the method -Gitee corresponds to the token used to create the repositoryCreate token method:- Click the link above and log in to Gitee, click generate new token,
- Add descriptions, such as use-Github repository syncs to Gitee;
- By default, all permissions are selected. Click Submit to display the token value. (Note to save, need to fill in Github secrets)
Finally, all subsequent submissions can be automatically synchronized using Github Action.
Plan a | Scheme 2 | Plan 3 | |
---|---|---|---|
advantages | 1. The configuration is simple 2. Ability to control submission sources |
1. The configuration is simple 2. Simple submission |
1. The configuration is cumbersome 2. Submission remains unchanged |
disadvantages | You have to submit it twice | Unable to control | Github Action gg if sanctioned |
Evaluation of the star | ⭐ ️ ⭐ ️ ⭐ ️ | ⭐ ️ ⭐ ️ ⭐ ️ ⭐ ️ ⭐ ️ | ⭐ ️ ⭐ ️ ⭐ ️ |
When I finished writing this article, there was some fermentation. When I saw 3-2, Github announced that it would still provide services without borders.
Lot. Blog / 2022-03-02 -…
But in this case someone else has been banned
So,
Backing up your data is important!
Backing up your data is important!
Backing up your data is important!
Tomorrow or accident which will come first we do not know, but we should do as much as possible to prepare for a rainy day!
Finally thank you for reading, please forward to those who need.
conclusion
❤️ follow + like + favorites + comments + forward ❤️, original is not easy, encourage the author to create better articles
Pay attention to the public number autumn wind notes, a focus on front-end interview, engineering, open source front-end public number