Git: Setting Up Git on GitHub
Here's minimum steps to setup git using GitHub.
First, install git on your machine.
which git → check if git is installed and path setup correctly. If so, you'll see a path. Else, nothing.
sudo apt-get install git → install git (Ubuntu Linux).
For git command line basics, see Git Tutorial: Practical Git in 1 Hour.
How to get code from github?
Go to a github site, you'll see “clone url”, copy the URL. Then, do this:
# clone a repository git clone https://github.com/xahlee/xah-svg-clock
This will create a dir of the project name in your current dir.
How to put your git repository on github?
① go to https://github.com/ to create a account.
② create a new project. On github site, click the “Create a New Repo” button, then fill out the form. You have to do this on github website.
③ on your machine, create your git repo if it doesn't exist.
# init git in my-project cd my-project git init git add . git commit . -m"initial commit"
④ On your machine, cd to your project dir, then create a association of a name and a remote repository URL. Like this:
git remote add name url → Associate the name name with the URL url of remote repository.
# associate a name to remote repo cd my-project git remote add github https://github.com/xahlee/my-project.git
This will associate the name “github” with that URL. So later on, you don't have to type the full URL when you want to push code to github.
That's it. You are done.
git push github master → push the “master” branch to the remote server. You can add a
--set-upstream) option. The
-u option will save you from typing a remote server name when you do
git pull github master → pull from github. This will update your local repository from github.
How to get your github id?
go to a url of this form:
replace your user name there.
Patreon me $5. Ask me question on patreon