Version Control part 4

Steven Klavins
2 min readMar 1, 2020

--

Week 1 — Version control

Connecting GitHub Remote Repositories

So say we have created a repository on GitHub, how do we connect that with a local repository on our computer? We use a remote! If we type git “remote -v” into terminal or gitbash we will obtain a list of our remotes, if we had never set up one we would simply have nothing show.

So how do we connect our repositories? We do so with “git remote add origin <YOUR_REPOSITORY_ADDRESS_HERE>” (ensure to do this whilst in your desired local git directory). Now once more run “remote -v” to ensure the remote is set up correctly, if it is you should receive a push and pull message. To establish the connection between GitHub use the “git push -u origin master” command, if successful you will receive a message notifying you your master branch is set up to track. The “-u” means these parameters should be saved as default, next time you push to GitHub you won’t need to add “origin master”. In a sense you could regard the “git push” command as a update/upload revision command.

So to summarize the process goes as follows

  1. Create the directory of your project.
  2. Initialize (init) the repository in your directory.
  3. Add the desired files to the project directory.
  4. Add the files you want to track to the staging area
  5. Commit the files
  6. Make a GitHub Repository
  7. Create a origin remote.
  8. Finally push the files to GitHub.

Ensure your in the selected directory whilst doing this!

Pulling from your repositories

Ok now what if we’re on a totally new computer and want to pull the code from our GitHub repository? We use the command “git pull origin master” to pull all the up to date code, or “git pull” to update. You can try out this concept editing a file directly from GitHub and committing the changes, then when you run the git pull command from your desktop you will see the changes applied.

Cloning repositories

So what if we want to clone and obtain someone else’s repository? For this we use the “git clone” command. First thing we will need to navigate to the desired repository on GitHub and copy the clone URL provided on the right hand side. We then enter the command “git clone” followed by the URL and press enter, this will clone the files into our selected directory.

Collaborating

Collaborating with others on GitHub is fairly straight forward, you simply send a invite to your selected partner on the GitHub website. When your partner excepts the invite they can then download and push commits to your repository. Remember to regularly check for there updates so you don’t miss anything out they may have changed.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response