Skip to content

MoOx/git-init

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

git-init

Repo on GitHub Repo on GitLab Repo on BitBucket

Keep in sync your Git repos on GitHub, GitLab & Bitbucket without efforts

Once Install some CLI tools

brew install hub
gem install gitlab
pip install bitbucket-cli

Note: be sure to have tokens as env var, see the beginning of this post for details.

(Also, configure a git alias that will do pull --all if you want to pull all remote by default.)

For each repos

  1. Export your username (assuming you have the same on all platforms)
export GIT_USER_NAME=$USER
  1. For new repo (if your repo already exist on GitHub, go to step below.)
export GIT_REPO_NAME=your-repo
mkdir $GIT_REPO_NAME && cd $GIT_REPO_NAME
git init
hub create
  1. For existing GitHub repo
export GIT_REPO_NAME=$(basename $(pwd))
gitlab create_project $GIT_REPO_NAME "{visibility_level: 20}"
bb create --protocol=ssh --scm=git --public $GIT_REPO_NAME

Then, to add remotes

git remote set-url origin --add https://gitlab.com/${GIT_USER_NAME}/${GIT_REPO_NAME}.git
git remote set-url origin --add https://bitbucket.org/${GIT_USER_NAME}/${GIT_REPO_NAME}.git
git remote add origin-gitlab https://gitlab.com/${GIT_USER_NAME}/${GIT_REPO_NAME}.git
git remote add origin-bitbucket https://bitbucket.org/${GIT_USER_NAME}/${GIT_REPO_NAME}.git
  1. Check that everything is ok
git remote -v

You should get something like

origin  ssh://[email protected]/YOU/YOUR-REPO.git (fetch)
origin  ssh://[email protected]/YOU/YOUR-REPO.git (push)
origin  ssh://[email protected]/YOU/YOUR-REPO.git (push)
origin  ssh://[email protected]/YOU/YOUR-REPO.git (push)
origin-bitbucket        ssh://[email protected]/YOU/YOUR-REPO.git (push)
origin-bitbucket        ssh://[email protected]/YOU/YOUR-REPO.git (fetch)
origin-gitlab   ssh://[email protected]/YOU/YOUR-REPO.git (fetch)
origin-gitlab   ssh://[email protected]/YOU/YOUR-REPO.git (push)

😇 Now you can just git push and git pull --all!

Bonus: badges

You can add some nices badges to show the redundancy on your project README

[![Repo on GitHub](https://img.shields.io/badge/repo-GitHub-3D76C2.svg)](https://github.com/YOU/YOUR-REPO)
[![Repo on GitLab](https://img.shields.io/badge/repo-GitLab-6C488A.svg)](https://gitlab.com/YOU/YOUR-REPO)
[![Repo on BitBucket](https://img.shields.io/badge/repo-BitBucket-1F5081.svg)](https://bitbucket.org/YOU/YOUR-REPO)

Adjust YOU/YOUR-REPO to your need in the markdown.

It will look like this

Repo on GitHub Repo on GitLab Repo on BitBucket

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published