Today we are gonna learn how to get started with git. The first thing you are gonna do is to create a local repository.
Now, lets go back to the local repository. Right click and select Git Bash Here
Now you will see the gitBash command prompt opens. As you opened the gitBash in the directory where we are going to do the operations, we are in the right place!
Now lets create a test file in the repository and a test folder. Then we can command
ls Which lists all the files and directories. So far so good. Now we need to go back to gitHub website. Log in and create a new repository. Copy the clone url. And get back to the bash window.
The first thing we need to do now is to configure git for our machine. In this case use the following two commands:
git config --global user.name "Your Name"
git config --global user.email "firstname.lastname@example.org"
Now we want to clone the github repository to our local machine. To that, lets use the following command,
git clone (url)
Here, the url is the url what you copied from github (Photo above).
Now we want to create some new files inside cloned the repository. Lets put the
ls command again. Then you will be able to see the cloned folder name. To enter inside it, use the follwoing command:
So far so good. Lets create some files and folders inside the cloned repository. You can put some texts in the files or whatever you want 😉
Now we want to commit them to the remote gitHub repository. Cool, lets do that right away!
First, we need to add the files with the following command:
git add -A
-A means to add all the files/folders that are changed/created.
Now you can run:
git commit -m "This is my first commit!"
-m means the message you want to put for this commit.
Now finally it’s time to push the committed files to the remote repo. To do that, lets run the command below:
git push -u origin master
That’s it! You have successfully uploaded the files and folders that you have created!