| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
A GitHub Action for syncing between two independent repositories using force push.
Always make a full backup of your repo (git clone --mirror) before using this action.
# .github/workflows/git-sync.yml
on: push
jobs:
git-sync:
runs-on: ubuntu-latest
steps:
- name: git-sync
uses: wei/git-sync@v3
with:
source_repo: "source_org/repository"
source_branch: "main"
destination_repo: "destination_org/repository"
destination_branch: "main"
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} # optional
source_ssh_private_key: ${{ secrets.SOURCE_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`
destination_ssh_private_key: ${{ secrets.DESTINATION_SSH_PRIVATE_KEY }} # optional, will override `SSH_PRIVATE_KEY`You can use GitHub repo shorthand like username/repository.
The ssh_private_key, or source_ssh_private_key and destination_ssh_private_key must be supplied if using ssh clone urls.
source_repo: "git@github.com:username/repository.git"or
source_repo: "git@gitlab.com:username/repository.git"The ssh_private_key, source_ssh_private_key and destination_ssh_private_key can be omitted if using authenticated https urls.
source_repo: "https://username:personal_access_token@github.com/username/repository.git"You only need to set up deploy keys if repository is private and ssh clone url is used.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"In GitHub, either:
or
Add the private key(s) to Repo > Settings > Secrets for the repository containing the action (SSH_PRIVATE_KEY, or SOURCE_SSH_PRIVATE_KEY and DESTINATION_SSH_PRIVATE_KEY)
To Sync all branches from source to destination, use source_branch: "refs/remotes/source/*" and destination_branch: "refs/heads/*". But be careful, branches with the same name including master will be overwritten.
source_branch: "refs/remotes/source/*"
destination_branch: "refs/heads/*"To Sync all tags from source to destination, use source_branch: "refs/tags/*" and destination_branch: "refs/tags/*". But be careful, tags with the same name will be overwritten.
source_branch: "refs/tags/*"
destination_branch: "refs/tags/*"$ docker run --rm -e "SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)" $(docker build -q .) \
$SOURCE_REPO $SOURCE_BRANCH $DESTINATION_REPO $DESTINATION_BRANCH| Back | FazBrowse Home | New Git URL |