Outline
- 1. Introduction
- 2. Github SSH for private repositories
- 2.1. Generate keys
- 2.2. Adding your SSH key to the ssh-agent
- 2.3. Add SSH Key to Github Account
- 3. Managing Branches(local/remote)
- 3.1 How to get branches from the remote repository
This document will give you instructions on how to manage your git on a development project on Github.
To access the private repositories, certain identification process is needed to. SSH keys are the id for it without login process. They are usually kept in ~/.ssh
. Without this, you will need to type your username and password to clone the private repository.
To generate keys, open terminal and paste this code, substituting with your Github email address.
ssh-keygen -t rsa -b 4096 -C "[email protected]"
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location. Or you can save your key with your own name /Users/you/.ssh/<your key name>
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
(Optional)To have extra security process, passphrase is used. If you still want to use password to prove your Github account, use it.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Before adding it to the agent, check for the existing ssh keys. This assumes that your ssh key name is id_rsa. If your key filename is different, replace it with your key filename.
- Start ssh-agent in the background
eval "$(ssh-agent -s)"
- If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
- Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.
ssh-add -K ~/.ssh/id_rsa
open git bash shell and do the same as MAC except configuration
- Start ssh-agent in the background
eval "$(ssh-agent -s)"
- Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.
ssh-add ~/.ssh/id_rsa
- Copy the SSH key to your clipboard.
If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don't add any newlines or whitespace.
pbcopy < ~/.ssh/id_rsa.pub
- Go go github SSH-GPG key settings
https://github.com/settings/keys
-
Click New SSH key or Add SSH key.
-
In the "Title" field, add a descriptive label for the new key.
-
Paste your key to the "Key" field.
-
Click Add SSH key.
-
If prompted, confirm your GitHub password.
On development process, developers manage the temporary software versions on a branch. This part goes through how to manage them efficiently.
First, clone the repository.
git clone <git link to the project>
Second, Look for all branches including local and remote. Remote branches are in remotes/origin
git branch -a
This will prompt all branches like this:
* (HEAD detached at origin/part2)
master
part1
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/part1
remotes/origin/part2
remotes/origin/part3
Third, checkout to a remote branch that you want to be work on. Files will be switched based on that branch.
git checkout <the branch that you want to work on>