How to Git- Pushing Files to Github repository

In this tutorial, we are going to learn how to start Github repository and Pushing Files to Github repository.
Github allows you to keep track the changes in a project. It allows you to make the public project. so it’s like a website. Once you publish your file on Github, anyone can go and they can look at your files, they can suggest some changes and everyone can collaborate.

Github provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project. GitHub offers premium private repositories for business needs. Let’s dive into how to create a public Github repository.

 Create a Github Repository

If you want to use github whether you’re publishing your own project or just helping out someone else, you need a Github account. To create an account in Github, go to github.com.  Fill out the username, email address, and password. Signup for GitHub.

 

GitHub Sign Up

Pushing to Github repository

 

Once you have the account setup, and you are logged in, click start project.

Let’s learn how to create a new public repository. Once you click on create a new repository, it will take you to the below page. On this page, you have to give repository project name. Let me just name as “Simple Website”.

You can add a description to your project which is optional.

You can choose a public or private repository, A public repository can see anyone, anyone can see the files inside it, anyone can download it and anyone can suggest changes. Private repository only can see authorized people and it’s a premium service. Here, we use a public repository.

Next, you can choose Initialize this repository, we are going to leave this unchecked because whenever we created a repository on git, we initialize it from the command line.

Now, click on create repository.

 

Creating Repository on GitHub

Pushing to a Github repository

 

Now, we have a public repository. It will give you the URL to connect our repository and instruction to connect from git bash command line. Let’s add our project.

 

 

Adding Project

Pushing to a Github repository

 

Pushing Files to Github Repository

We have a project “Simple-website” on our local computer which need to add it to our public GitHub repository. Firstly, Initialize the “Simple-website” and add all files using git add . , then commit all the project files.

 

Pushing Files to GitHub
	 yp@yp-PC MINGW64 ~ (master)
	 $ cd Simple-website

	yp@yp-PC MINGW64 ~/Simple-website (master)
	$ git init
	Initialized empty Git repository in C:/Users/yp/Simple-website/.git/

	yp@yp-PC MINGW64 ~/Simple-website (master)
	$ git add .
	warning: LF will be replaced by CRLF in css/kube.css.
	The file will have its original line endings in your working directory.

	yp@yp-PC MINGW64 ~/Simple-website (master)
	$ git commit -m "First commit"
	[master (root-commit) 29048db] First commit
	 37 files changed, 10939 insertions(+)
	 create mode 100644 css/custom.css
	 create mode 100644 css/custom.min.css
	 create mode 100644 css/font-awesome.min.css
	 create mode 100644 css/kube.css
	 create mode 100644 css/kube.min.css
	 create mode 100644 fonts/FontAwesome.otf
	 create mode 100644 fonts/fontawesome-webfont.eot
	 create mode 100644 fonts/fontawesome-webfont.svg
	 create mode 100644 img/avatar.png
	 create mode 100644 img/favicon.png
	 create mode 100644 img/head-bg.jpg
	 create mode 100644 img/post-img.jpg
	 create mode 100644 img/separator.png
	 create mode 100644 index.html
	 create mode 100644 js/accordion.js
	 create mode 100644 js/autocomplete.js
	 create mode 100644 js/buttons.js
	 create mode 100644 js/check-all.js
	 create mode 100644 js/dropdown.js
	 create mode 100644 js/filterbox.js
	 create mode 100644 js/infinite-scroll.js
	 create mode 100644 js/jquery.min.js
	 create mode 100644 js/kube.js
	 create mode 100644 js/kube.min.js
	 create mode 100644 js/livesearch.js
	 create mode 100644 js/message.js
	 create mode 100644 js/modal.js
	 create mode 100644 js/navigation-fixed.js
	 create mode 100644 js/navigation-toggle.js
	 create mode 100644 js/progress.js
	 create mode 100644 js/tabs.js
	 create mode 100644 js/textfit.js
	 create mode 100644 js/tooltip.js
	 create mode 100644 js/upload.js
	 create mode 100644 js/validate.js

 

Now, open up GitHub repository that we created earlier. copy our public repository URL and append it with git remote add command

 

Local access to Github
    git remote add nickname github_url 
    //Nickname is the alias of github url

 

Let’s connect to our GitHub repository.

 

Connect to Github
    yp@yp-PC MINGW64 ~/Simple-website (master)
    $ git remote add MyGitHub https://github.com/Lauyou01/Simple-Website.git

    yp@yp-PC MINGW64 ~/Simple-website (master)
    $ git remote
    MyGitHub

 

Now we have a connection to our public repository with a nickname “MyGitHub”. You can check the current connections using git remote command. Let’s add our project files to the public repository.

To add files, use git push -u <nickname> master command.  Once you issue the push command, a login tab will prompt. Fill out you GitHub credentials and log in.

 

GitHub Login

Pushing to a Github repository

 

Once you log in, it will start to upload our project files to the public online repository.

 

Upload with push command
	yp@yp-PC MINGW64 ~/Simple-website (master)
	$ git push -u MyGitHub master
	Counting objects: 43, done.
	Delta compression using up to 2 threads.
	Compressing objects: 100% (43/43), done.
	Writing objects: 100% (43/43), 482.33 KiB | 0 bytes/s, done.
	Total 43 (delta 7), reused 0 (delta 0)
	remote: Resolving deltas: 100% (7/7), done.
	To https://github.com/Lauyou01/Simple-Website.git
	 * [new branch]      master -> master
	Branch master set up to track remote branch master from MyGitHub.

 

Let’s go and check out your GitHub public repository. you can see all of the project files.

 

Project files preview

Pushing to a Github repository

 

Anyone can see this files, anyone can download and make changes and submit. Anyone can suggest some changes and everyone can work collaboratively.

Muhsin Yakkiparamban

Muhsin Yakkiparamban is the co-founder of Lauyou Learning. Muhsin holds Bachelor Degree in Civil Engineering from KMCT Calicut.

You may also like...