简体   繁体   中英

Add a remote to a GitHub repository

I have a GitHub repository, say https://github.com/mrpandey/proj .

On my local clone of this repo, I have the following two remotes (both fetch and push):

ser    ssh://git@server.com:2222/proj.git
origin https://github.com/mrpandey/proj.git

ser is the git server of a platform where I deploy this project. To automate the deployment process, I was writing a GitHub Actions workflow. The workflow needs to push to ser whenever changes are pushed to main branch of GitHub (origin).

The problem is that ser is not added as a remote on origin . I verified this by running git remote -v in the workflow script.

So, how can I add a remote to the GitHub repo?

I tried pushing my local to the origin, but ser doesn't show up on origin. GitHub does not provide shell access through ssh, so can't even run remote add on origin.

One way is I could run remote add in the workflow script itself. However, I would like to know if there is actually a possibility to add another remote to a GitHub repository without the help of GitHub Actions.

Your remotes aren't part of the repository; they're not pushed to github when you push your changes. Remotes need to be configured in each individual working directory.

You would need to configure the remote in your workflow script by running the appropriate git remote add ... command:

git remote add ser ssh://git@server.com:2222/proj.git

Then you could run git push ser

Alternately, you can push directly to a git URL. For example, your workflow script could run:

git push ssh://git@server.com:2222/proj.git

Of course, for this to work, you'll need to have ssh keys configured appropriately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM