Linux | Cloud | DevOps | Scripting

Breaking

Friday, 14 June 2019

Create a repository on GitHub


Resources used:

  1. OS Name: CentOS Linux
  2. OS Version: 7 (Core)
  3. git Version: 1.8.3.1
  4. Project Location: /home/Divakar/webshack

Steps we need to follow:
  1. Install git
  2. Verify project data
  3. login to GitHub
  4. Create an empty repository
  5. Initialize git on the local folder
  6. Add GitHub repo remote
  7. Add files to the staging area
  8. Make a commit
  9. Push the data on GitHub
  10. Verify repository on GitHub

Step 1: Install git:
$ sudo yum -y install git 
Verify version:
$ git --version 
Step 2: Verify project data:
I have my data on location /home/Divakar/webshack

Contents we need to push on GitHub repository
Data to migrate on GitHub

Step 3: login to GitHub:

Open browser ➔ go to URL: https://github.com  ➔ Sign in to the GitHub account OR if you do not have GitHub account, then create your account and Sign in.

Step 4: Create an empty repository:

GitHub Account ➔ Click on the upper right side plus icon ➔ New repository ➔ Repository name: webshack ➔ Description: <provide detailed description about this repository> ➔ [*] Public (In 'Initialize this repository with a README' select Public only. If we choose Private, then we need to pay some amount, so for learning purpose just click on Public repo) ➔ (Leave this uncheck 'Initialize this repository with a README' otherwise history for this repo will be created and then we will not be able to push data on the same branch) ➔ Create repository.

Create a new repository on GitHub
GitHub New Repository

This will provide us two ways to setup this repo in Desktop, one is using HTTPS and another way is via using SSH. For SSH, we need to use keys. So, for the time use HTTPS link, I will describe how to use SSH link in another post.

Step 5: Initialize git on the local folder:

Go to terminal ➔ Navigate to /home/Divakar/webshack folder:

$ cd /home/Divakar/webshack

$ git init
Initialized empty Git repository in /home/divakar/webshack/.git/

By listing, we can see that a folder named '.git' is added

Step 6: Add GitHub repo remote:

To check, is there any remote added or not:

$ git remote

If any remote repo is added that will be listed here.
Now, add our GitHub repo:

$ git remote add origin <HTPS URL>

Now, the whole https path will be known as 'origin' and if you use 'git remote' command now, it will reply as 'origin'.

Step 7: Add files to the staging area:

$ git add .

Make sure you use a dot ( . ) after add.

Step 8: Make a commit:

The "commit" command is used to save your changes to the local repository.

$ git commit -m "initial commit"

If we use 'git status' command, this replies that working tree is clean. So, now we can push our data on our GitHub account.

By using command 'git log' we can verify our initial commit.

Step 9: Push the data on GitHub:

The 'push' command publishes new local commits on a remote server.

$ git push -u origin master

As you use push command, this will ask for username and password for GitHub account. Provide username and password and this will push the data on the GitHub account.

Step 10: Verify repository on GitHub:

Go to the browser on GitHub account from where we copied https link of our repository ➔ Refresh the page.

Yaayyyyyy!

All data is migrated to GitHub.




No comments:

Post a Comment

Pages