...
git fetch origin
git rebase origin/master
git reset --hard origin/master
(Check before doing this that git status is clear)
Using Multiple Deploy Keys
One way to pull code from Git to a server is to add a public SSH key as a Deploy Key in the Repo Settings. There is a problem though that each Deploy Key can only be used on one GitHub repo which requires multiple Keys. You then have the problem of telling Git which key to use with which repo.
Generate an SSH keypair per repo as usual (albeit with a unique filename) and add it to the repo as a Deploy Key.
Create a .ssh/config file which looks similar to the following -
Code Block | ||
---|---|---|
| ||
Host github.com
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/bamboo
Host github.com-data_extract
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/data_extract_key
Host github.com-ukrdc_database
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/ukrdc_database_key
Host github.com-ukrr_quarterly_extract
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/ukrr_quarterly_extract_key |
Host github.com-data_extract
This is the important part which we’ll be using in the git clone command. I have used the same value as the repo name (as with the key filenames) but I believe it just needs to be a unique value.
Clone using a command similar to -
git clone git@github.com-data_extract:renalreg/data_extract.git
Note the modified hostname to match the reference in the config file.
The first entry in the config file specifies which key will be used by default where the hostname hasn’t been modified i.e. via pip/poetry.
The key here has had to be added to the “bamboo” build account in GitHub as one of its keys.
If you have had to do this then it does make the use of the deploy keys irrelevant.
Useful reference Articles/Sites
...