Introduction to Github¶
To create a repository¶
You can sign in to our Github using your King's account (kxxxx) at https://github.kcl.ac.uk/ Once signed in, you can click "new" to create a new repository, give it an identifiable name and click "Create repository". If creating a new site from scratch you may wish to tick "Initialize the project".
To setup for webfarm deployments¶
Once you have created a repository, you will need to setup a few things so the webfarm can see your repository.
- Navigate to the new repository and click settings
- Select "Deploy keys" and click "Add deploy key"
- Paste the deploy key found in Portal when you view your site ("Public Key")
- Now click "hooks" and then "Add webhook"
- In Portal, click "Generate a new webhook URL" and paste the URL into "Payload URL"
- Leave everything else, and click "Add webhook"
Once you have your repository setup, you will want to checkout to your local machine. How you do this will depend on your operating system and personal preferences (GUI vs CLI).
Setup your local machine - Windows / GUI¶
To sign into Github Desktop¶
- Go to File->Options->Accounts. Under "Github Enterprise" click "Sign in".
- Type "https://github.kcl.ac.uk" and click "Sign in via web browser".
- Login using your KCL account details (kxxxx and your password).
- Click "Authorize github-enterprise".
- If prompted to "Open githubdesktop.exe" click "allow".
To clone a repository (windows)¶
- Click File->Clone a Repository.
- Click the "Github Enterprise" tab and select the repository you wish to clone.
- Select an appropriate local path and click "Clone".
To deploy changes (windows)¶
As you make changes to your website, you can commit them within the Github Desktop application. You need to enter a description for each change, but this is only really for you to refer back to later. If you have committed local changes, there will be an option to "Push origin", click this to push changes up to Github and deploy the changes to our servers.
Setup your local machine - Linux / CLI¶
- Go to https://github.kcl.ac.uk/settings/keys.
- Follow the instructions for "generating SSH keys" (
ssh-keygen -t ed25519 -C "firstname.lastname@example.org").
- Click "New SSH key" and paste in the public key you generated.
To clone a repository (linux)¶
git clone email@example.com:USERNAME/REPO.git
To deploy changes (linux)¶
git add --all
git commit -am "COMMIT MESSAGE"