How to Git ? Make you first push ?



In this article we will be uploading our project files to  Github using Git commands.

Before we start using git , we have to have it installed. Visit Here to download git and install it in your machine. It's an GUI based installation.


Now that we have our Git installed, we will start using it to upload our code to github.


1. Initialize project folder with git.

for this article I have created a folder that contains my project files.


and I have only one file in it.

Now somehow we have to tell git to start monitoring any changes in this folder.

For that we have to open git bash in this folder and write git command "git init".

after running this command it should say "Initialized empty Git repository".

Now , you have initialized you project folder and any changes from now on will be tracked by git .
To check this , write "git status" in git bash and see what appears.


it says untracked files , becuase it was there before we told git to monitor this project folder i.e before initialized this folder with git.


2. Stage changes

Now we have to stage our changes , staging simply means you are telling git to add the changes in the file.
to add all the files of your project write "git add .".
Here '.'(dot) means all the files.
 

after writing add command again run "git status" and compare with when you wrote first time.
It's now saying "new file : New Text Document.txt".

It means git has staged the files and they are ready to commit.


3. Commiting your changes

commit is a way to tell git to store the current file as it is and mark a point so that if any changes occurs later we can move back to this mark where we had committed.

after commit it show the number of files that has been committed.


4.Creating repo on Github and uploading project to it.

now that you have committed your changes ,it's time to put your project on github. For this you need an github account , after creating your account create a repository and name it as your project name(or what ever you like).



I named my repo , git-test. click create repository.

on clicking on create repository , it will give you a repo link , copy it.

we will use this repo link to upload our project to this repository.

now open you git bash and write these command one after other respectively.

git remote add origin <YOUR REPO LINK> "   

git push -u origin master "



see how I have replaced '<YOUR REPO LINK> ' with my actual repo link that we copied.
this links your local git to the github repository that you just created.

"lastly git push -u origin master " , pushes the project to the actual repo on github.
If you will refresh the github page you can see your project files  there.



This is how you can push you files to github.

Here I have not covered many topics like branch , merge ,rebase . we will discuss these topics in future blogs.


Comments

Popular posts from this blog

Implement something like *ngFor of angular using Vanilla js .

Making service call in Angular