Skip to content

hsrwrobotics/hello-git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro to Git

The Basics

diagram showing git workflow

Installing git

If using Linux or MacOs, git should probably be present already. If not, follow the insttructions here.

For Windows, download the installer from here.

Cloning a repo

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

Pushing to a repo

The three step process

  1. git add <files paths>
  2. git commit -m "<commit message>"
  3. 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

Pulling a repo

Make sure you have the latest files locally, before pushing

git pull origin main

Hosting a static website

I set up a simple portfolio template for you to use.

Forking a repo

fork icon

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).

Creating a branch

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

Pushing to branch

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 use git add . or even git commit -a to make things easy, although this is not recommended until you actually have a proper .gitignore set up.

Participants

  • Thomas

References

About

An intro to git,github and static pages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published