A Guide to Git commands
Create a local repo
git init
Stage files to the local repo (i.e. add them to the bag)
git add .
Commit files (i.e. tell git the files are ready to be sent)
git commit -m "anything you want to write"
Sign Up / Login to Github
Create a new remote repo at Github and copy the repo address
Tell your local repo the address of the Github repo
git remote add origin <your repo address here>
Push your commits to the remote repo
git push origin master
NOTE: The next time you make any changes to your code, you do NOT have to git init
or git remote add
again.
-
Any time you can check your commit history using the command
git log
-
Any time you can check the status of your local repo using the command
git status
-
If you get an error while running the
git commit
command, add your email and username using these commands:git config --global user.name "<your name here>"
git config --global user.email "<your github email>
The
--global
tellsgit
to remember your name and email so you do not have to type it again when you create a new repo on the same computer.
To publish your website to Github Pages:
- Make sure your home page is named
index.html
- Once you have pushed the code to Github, go to Github repo Settings, scroll down to Github Pages, select Master Branch from dropdown, and click save. When the page reloads, it will show you the link to your website accessible from anywhere in the world.