GitHub Repository Setup, Clone and Push using Git

Taimoor Sattar author Posted on
Github is the server way (web hosting service) for version control system using Git, tracks your files and coordinating work on those files among different people. In order to best understand GitHub, I recommend you to look at the local way of version control system, Git. Here are some of the terms that we will be looking at this blog:
  • Repository Setup
  • Setup remote URL
  • Clone Repo
  • Push Repo
Repo and Repository are both same thing.

Repository Setup

It is similar to folder present at you local computer. Github called it repository. In order to create a repository, click add new button after signing into the GitHub account. It will ask you the name of the repository. For example, In the computer, folder location is C:\Users\github\Desktop\github-main and In Github, repository location is: https://github.com/YourAccount/repository-name.git

Setup remote URL

In Github, You can create multiple repositories folders. And you can also look at the people public repository. You can clone and push from your repository but you can only clone from other people repository. You are working on the local computer, in order to communicate to the repository on GitHub you want to set URL. For this enter, this command. [formatc lang="markup"]git remote set-url origin https://github.com/YourAccount/repository-name.git[/formatc] In order to check your remote URL set, Enter this command:  [formatc lang="markup"]git remote -v[/formatc]

Clone repo

It stands for moving GitHub repository from the local computer. It means copy one folder into another folder. In order to set which repository URL you want to clone you have to set URL by this command: [formatc lang="markup"]git remote set-url origin https://github.com/YourAccount/repository-name.git[/formatc] Enter the GitHub repository URL to clone to the local hard drive [formatc lang="markup"]git clone https://github.com/YourAccount/repository-name.git[/formatc]

Push Repo

Push is opposite to clone. Push stand for moving your local project folder to the GitHub repository. In order to achieve, set the repository URL [formatc lang="markup"]git clone https://github.com/YourAccount/repository-name.git[/formatc]
As you are familiar with these basic terms. Now, we shall move toward the real project. Create a folder github-main in the local computer and inside this folder create index.html and style.css and place dummy HTML and CSS in the file, git add -A all the files and commit the changes; as explained in this section of the blog. Now, you are set up locally and ready to move to the repository. git command Before going on, Sign up or log in to GitHub account. While signing up, they may ask you about the plan; Just choose a free plan which means public repository. The private repository is only needed when you have an important file that you don't want to share in public. Github Signup Go to the GitHub and create a new repository by clicking add repository or look at the + symbol on top, then choose a repository name. Now, on terminal window enter this command at explaining in the picture: GitHub Push [formatc lang="markup"]git remote add origin https://github.com/user-name/my-repo.git git push -u origin master[/formatc] Refresh your repository, Now you will see that your files move to the repository.

Setup project for Clone

Now it is time to move your files from your repo to local computer folder. Make a folder 'my-folder' where to want to move your files. Note that you want to type cd(change directory) to your 'my-folder' where you want to move repository files. Then type this command. Git Clone [formatc lang="markup"]git clone https://github.com/underlinejobs/my-repo.git[/formatc] Now, you have move files from this repo to your local folder.