If using Linux or MacOs, git
should probably be present already. If not, follow the insttructions here.
For Windows, download the installer from here.
Click on the green Code
button on the repo page, copy the https
link. Open a terminal and move to desired folder. Then run the git clone
command along with the copied url to create a local copy of the repo.
So, to clone this repo, the command would be
git clone https://github.com/hsrwrobotics/hello-git.git
The three step process
git add <files paths>
git commit -m "<commit message>"
git push <remote> <branch>
For this repo, add your name to the Participants section of this markdown file and save it. Then
git add README.md
git commit -m "First commit"
git push origin main
Make sure you have the latest files locally, before pushing
git pull origin main
I set up a simple portfolio template for you to use.
Click on the Fork
button to create a remote copy first. Then go to this forked repo page and clone it(Notice the url of the fork is different from the original).
We will create a branch called pages
which will used to host the website(basically what is contained in the website
folder in the repo)
The easiest way
git checkout -b pages
In order to use the Github pages
feature, the index.html
needs to be located either in the root directory or in a docs
folder. So, let's make this change first. Make sure you are in the pages
branch of your forked repo.(You can check this by running git branch
command from the terminal, the current branch that you are on should be highlighted). Rename the folder using git and then push the chnages to the correct branch
git mv website docs
git commit -m "updating webpage"
git push origin pages
Head over to Github page on your browser, and go to Settings
-> Pages
tab. Set Branch
to pages and click on Save
. And now we wait... In about 3-5 minutes, you should see a message that says your website is live(Refresh your page if you dont see a message even after 5 minutes). Click on the url to open it up.
The urls normally follow the format hhtps://<github userID>/<Repo name>/
Open the html
file and edit it to your needs(like replacing NAME HERE
with your own name). Push these changes and watch the page rebuild to display the updated info.
git add .
git commit -m "updating webpage"
git push origin pages
.
is used to when you want to select everything. So, if you have a lot of files that need to be push, you could usegit add .
or evengit commit -a
to make things easy, although this is not recommended until you actually have a proper.gitignore
set up.
- Thomas