Reputation: 1009
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://[email protected]: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.
Upvotes: 1
Views: 967
Reputation: 311238
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://[email protected]: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://[email protected]:2222/proj.git
Of course, for this to work, you'll need to have ssh keys configured appropriately.
Upvotes: 2