Skip to content

Git Remote Repository

Remote repositories(repo) are a copy of your local repo hosted on a web service like GitHub or GitLab. Collaborating with other developers on your test automation project requires a basic understanding of the remote repository.

In this code note, we will cover the following topic we went over during our training session.

  • SSH Key Configuration
  • Remote Repository



› SSH Key Configuration

Before working with the Remote repo on GitHub, we must register our local device to your GitHub profile by adding public SSH key generated by your computer. Following six steps show you the details of this configuration:

  1. Open your Terminal
  2. Type the following command
     ssh-keygen -t rsa -b 4096 -C "email"  # provide email used for GitHub 
    
  3. Press   Enter   key for every prompt
  4. Display the content of generated public key
    cat ~/.ssh/id_rsa.pub
    
  5. Copy the public key content
  6. Paste the public key content to SSH account section

Please watch this instructions video for a complete SSH Key configuration walk-through:

Please note that SSH Key configuration is one-time activity per device. So if you have configured once for your laptop, you do not have to do it again.



› Remote Repository

If you have a local repo, then there must be a corresponding remote repo for you to collaborate with others and as well as to save development back-ups. To see if your local repo has a remote repo, execute the following command on the project root directory.

git remote -v

If the command output shows links like these, your local repo has a corresponding remote repo.

On the other hand, if the output is an empty line like this, your local repo does not have a corresponding remote repo.

Setting up remote repo is simple and can be achieved by following these ten steps:

Commands seen on the slides:

1
2
3
git remote -v                          # see if remote repo exist
git remote add origin remote_repo_url  # register remote repo location
git push -u origin master              # push local repo to remote repo

Please watch this instruction video if the above slide steps are unclear.

Once your local repository has a corresponding remote repository, you can publish subsequent changes with simple push command.

git push