Making a Repository on Git
Hello, If you are new to git and want to make a new repository on git, this is the right article to read for the start. First of all, let us see what is a git repository, it is a directory on your account which stores your work for version control. Version control means you can manage the changes in the future, i.e. you can manage the version of your repository.
This article is written assuming that you have a git account, now follow the steps below to make a repository on the git.
1. Sign in to your git account.
2. After sign in you will see a + icon on the right upper corner of the window, click on the icon and than on add new as shown in the snapshot below :
3. After clicking on new repository you will see a screen asking for the name of repository, description, whether public or private(public is free and private is payable so we will use public), if you want to initialize the directory than check the checkbox as shown in the image below. Finally click on the create repository button.
4. After this you will see a screen showing your repository with a readme file, observe the red circles in the image below to have a clear idea about the same. Now we will upload our files of login example to our repository through command line. For this we need to have the url of our repository which you can copy from the circled part in the image or you can copy it from the url bar of browser.
5. Now open command prompt(in case you are using windows) or terminal(in case you are using ubuntu). Now go the directory through terminal. In my case it is the www/loginphp directory.
3. After clicking on new repository you will see a screen asking for the name of repository, description, whether public or private(public is free and private is payable so we will use public), if you want to initialize the directory than check the checkbox as shown in the image below. Finally click on the create repository button.
4. After this you will see a screen showing your repository with a readme file, observe the red circles in the image below to have a clear idea about the same. Now we will upload our files of login example to our repository through command line. For this we need to have the url of our repository which you can copy from the circled part in the image or you can copy it from the url bar of browser.
5. Now open command prompt(in case you are using windows) or terminal(in case you are using ubuntu). Now go the directory through terminal. In my case it is the www/loginphp directory.
1
| ajeet@ajeetpc:~$ cd /var/www/loginphp
|
6. Now we will initialize git in the directory with the help of the following command, i have used sudo before git init command because i am using ubuntu and sudo is for root permission.
1
| ajeet@ajeetpc:/var/www/loginphp$ sudo git init
|
7. After initializing git, our directory will act as a local git repository. Now we need to add the files which are in the directory but they are not tracked by git so we need to add them to our git local repository with the help of following command.
1
| ajeet@ajeetpc:/var/www/loginphp$ sudo git add -A
|
8. Now we need to commit the changes in our local repository with the help of the following command.When you run this command it will open an editor to enter a commit message. Type a commit message, I typed "This is my first commit". Save with ctrl+o and than press enter than ctrl+x to exit from the editor(in case of ubuntu terminal).
1
| ajeet@ajeetpc:/var/www/loginphp$ sudo git commit -a
|
9. The files are been added in our local git repository. We have created a readme file on our remote repository so first we need to have those changes in our local repository. We will pull the changes (readme file) to our local repositroy with the help of the following command.
1
| ajeet@ajeetpc:/var/www/loginphp$ sudo git pull https://github.com/AjeetK/login-example-php
|
10. You can check now the readme file is been pulled in our local repository, Now we will send the changes( or the new files which are added to the local repository) to our remote git repository with the help of the following command. Enter the username and password of git when prompted.
1
| ajeet@ajeetpc:/var/www/loginphp$ sudo git push https://github.com/AjeetK/login-example-php
|
That is all you need to do, your repository has been created which you can check on github.com which is shown below in the snapshot.
The live repository can be seen on this link.
0 comments:
Post a Comment