Skip to content
Snippets Groups Projects
Commit 386c98b1 authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

add git sync tool

parent eba76118
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,33 @@ There is a lot of ways how to use git and sometimes a working solution can be ve ...@@ -3,6 +3,33 @@ There is a lot of ways how to use git and sometimes a working solution can be ve
[[_TOC_]] [[_TOC_]]
## HowTo add a specif ssh-key for your git account
Sometimes it might be useful to have different ssh-keys per project or have a special ssh-key just for github/gitlab.
Steps:
1. Generate a `ssh-keygen`
2. Add ssh-key to GitHub or GitLab account under settings
3. Write a `~/.ssh/config` file with a content like this
```
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_for_git
Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa_for_gitlab
```
Make sure that you adjust the `Hostname` accordingly and be sure that you use ssh in your git repo:
```bash
$ git remote -v
origin git@github.com:USER/repo.git (fetch)
origin git@github.com:USER/repo.git (push)
```
show no `https` in the urls.
## HowTo Sync a GitHub and a GitLab repository ## HowTo Sync a GitHub and a GitLab repository
It is easy to import a GitHub repo into GitLab and the otherway around. However, if you want to make sure you can have both repos at the same state, you need to syncronize them. It is easy to import a GitHub repo into GitLab and the otherway around. However, if you want to make sure you can have both repos at the same state, you need to syncronize them.
......
...@@ -9,6 +9,16 @@ if [ "$#" -ne 3 ]; then ...@@ -9,6 +9,16 @@ if [ "$#" -ne 3 ]; then
exit 1 exit 1
fi fi
# Check if you are at root level (fails if not)
if ! git rev-parse --show-toplevel; then
>&2 echo "Git repo found"
if [ $PWD == $(git rev-parse --show-toplevel) ]; then
echo "Not at root of local repo"
echo $(git rev-parse --show-toplevel)
exit 1
fi
fi
if [ ! -d ".git" ]; then if [ ! -d ".git" ]; then
echo "Git repo for syncronization is not found, creating one..." echo "Git repo for syncronization is not found, creating one..."
git init git init
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment