Tech Junkie Blog - Real World Tutorials, Happy Coding!: git & github: Sync Your Local Repository With A github Repository

Monday, September 2, 2019

git & github: Sync Your Local Repository With A github Repository

In the previous post we created a local git repository, in this post we are going to create a remote repository in github and link it to the local repository that we created.

Here are the steps to create a new repository in github:

1.  Log into your github account and click on the "New" button next to the text "Repositories"












2.  Give the repository a name, I am going to name it "NorthwindCafe"


























You can set the repository to be public or private, if you don't have a paid account you can only create public repositories.  But if you have a paid account it might be a good idea to work privately first before you share your work with the reset of the world.

3.  Accept all the default settings and click "Create repository"



















4. When you get to the next page you will have instructions on how to link your local repository to the github repository if you scrolled down.








Since we already have a local repository the above command is what we want.
git remote add origin https://github.com/techjunkiejh/NorthwindCafe.git obviously your URL will look different than mine because it would be your github's username and not mine.

5.  Now open up the command line in your local repository and type in the command like the instruction says, if you run the command and then type git remote -v you will see that you can now fetch and push code to the repository










6. We are not done yet, now we have to push the code from our local repository with this command git push -u origin master which basically means push the code from master (local) to origin (remote).  If you get prompted, type in your github credentials























7. Now if we check online in github we will see the contents of our local repository in github





















Previous: git & github: Create a Local NorthwindCafe git Repository

1 comment:

Search This Blog