This tutorial shows how can beginners start uploading their projects on github. The description of the commands and steps followed are provided below :
Steps to follow :
1) Install Git : brew install git or sudo apt-get install git. Mac Users can just type git --version and follow the prompt given from Xcode command line tools.
2) Configure your username/email :
git config --global user.name "Emma Paris"
git config --global user.email "[email protected]"
Then Create your remote repository from your github account.
3) Now Navigate to your local project folder then run the following:
git init
Note : Creating react app automatically adds initial commits.
git add . ( Run this , if its not a React project )
git commit (Run this , if its not a React project )
then finally,
git remote add origin YOUR_REMOTE_REPOSITORY_URL
git push -u origin master
That's it. Done
Understanding the commands :
git init : It creates the new local git repository or reinitialises an existing one. It even creates a .git subdirectory in the current working directory, which contains all of the necessary Git metadata for the new repository. In this video, I made a react project which automatically initialised git repo. So when i ran git init , it reinitialised the repo
git remote add origin YOUR_REMOTE_REPOSITORY_URL : To communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [email protected]:peter/first_app.gitcreates a new remote called origin located at [email protected]:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.
git push -u origin master : A command that says "push the commits in the local branch named master to the remote named origin". Once this is executed, all the stuff that you last synchronised with origin will be sent to the remote repository and other people will be able to see them there.