Publishing via GitHub

Now let‘s take you through how to publish your site via GitHub pages. We aren‘t saying this is the only way or even best way to publish your site, but it is free, fairly simple, and touches upon some new skills that you‘ll find useful going forward.

Basic setup

  1. First of all, install Git on your machine. This is the underlying version control system software that GitHub works on top of.
  2. Next, sign up for a GitHub account. It‘s simple and easy.
  3. Once you‘ve signed up, log in to github.com with your username and password.
  4. Next, you need to create a new repo for your files to go in. Click Plus (+) in the top right of the GitHub homepage, then choose New Repository.
  5. On this page, in the Repository name box, enter username.github.io, where usernameis your username. So for example, our friend bobsmith would enterbobsmith.github.io.
  6. Click Create repository; this should bring you to the following page:

Uploading your files to GitHub

This is where we will have a go at using the command line to put our repository on GitHub. A command line is a window where you type in commands to do things like create files and run programs, rather than clicking inside a user interface. It will look something like this:

Note: You could also consider using a Git graphical user interface to do the same work, if you feel uncomfortable with the command line.

Every operating system comes with a command line tool:

  • WindowsCommand Prompt can be accessed by pressing the Windows key, typingCommand Prompt, and choosing it from the list that appears. Note that Windows has its own command conventions differing from Linux and OS X, so the commands below may vary on your machine.
  • OS XTerminal can be found in Applications > Utilities.
  • Linux: Usually you can pull up a terminal with Ctrl + Alt + T. If that doesn‘t work, look for Terminal in an app bar or menu.

This may seem a bit scary at first, but don‘t worry — you‘ll soon get the hang of the basics. You tell the computer to do something in the terminal by typing in a command and hitting Enter.

  1. Point the command line to your test-site directory (or whatever you called the directory containing your website). For this, use the cd command (i.e. "changedirectory"). Here‘s what you‘d type if you‘ve put your website in a directory calledtest-site on your desktop:

    cd Desktop/test-site
    

      

  2. When the command line is pointing inside your website directory, type the following command, which tells the git tool turn the directory into a git repository:

    git init
    

      

  3. Next, go back to the GitHub site. On the current page, you are interested in the section …or push an existing repository from the command line. You should see two lines of code listed in this section. Copy the whole of the first line, paste it into the command line, and press Enter. The command should look something like this:

    git remote add origin https://github.com/bobsmith/bobsmith.github.io.git
    

      

  4. Next, type the following two commands, pressing Enter after each one. These prepare the code for uploading to GitHub, and ask Git to manage these files.

    git add --all
    git commit -m ‘adding my files to my repository‘
    

      

  5. Finally, push the code up to GitHub by going to the GitHub web page you‘re on and entering into the terminal the second of the two commands we saw in step 3:

    git push -u origin master
    

      

  6. Now when you go to your GitHub pages‘ web address in a new browser tab (username.github.io), you should see your site online! Email it to your friends and show off your mastery.

Note: If you get stuck, the GitHub Pages homepage is also really helpful.

Further GitHub knowledge

If you want to make more changes to your test site and upload those to GitHub, you simply need to make the change to your files just like you did before. Then, you need to enter the following commands (pressing Enter after each one) to push those changes to GitHub:

git add --all
git commit -m ‘another commit‘
git push

  

You can replace another commit with a more suitable message to describe what change you just made.

We have barely scratched the surface of Git. To learn more, start off with the GitHub Help site.

Conclusion

By this point, you should have your sample website available at a unique web address. Well done!

Further reading

时间: 2024-10-10 22:19:44

Publishing via GitHub的相关文章

Bookmarks_www2

Bookmarks Bookmarks alexis- (Alex Incogito) - Repositories · GitHub GitHub - aetcnc-Arduino_DeltaHMI_RS485 Open source info describing how to connect an industrial HMI to an Arduino using RS485 Modbus GitHub - AlexandruScutaru-WorldEditor World edito

github pages

http://zyip.github.io/facemaker/index echo "hello world" >>hello.htm git init git add hello.htm git commit -m "add hello.htm" git remote add origin https://github.com/zyip/facemaker.git git push -u origin master $ cd your_repo_ro

【翻译】GitHub Pages Basics 基本使用帮助【首页】

页面链接:https://help.github.com/categories/github-pages-basics/ 翻译的是github网站关于github pages的介绍 GitHub Help Categories / GitHub Pages Basics  ----->  分类 / GitHub Pages 基本介绍 What is GitHub Pages? GitHub Pages 是什么? Configuring a publishing source for GitHub

【翻译】GitHub Pages Basics 基本使用帮助【一】GitHub Pages 是什么?

https://help.github.com/articles/what-is-github-pages/ What is GitHub Pages? --> GitHub Pages 是什么? GitHub Pages is a static site hosting service. GitHub Pages 是一个静态网站托管服务 GitHub Pages is designed to host your personal, organization, or project pages

Github 的一个免费编程书籍列表

Index Ada Agda Alef Android APL Arduino ASP.NET MVC Assembly Language Non-X86 AutoHotkey Autotools Awk Bash Basic BETA C C# C++ Chapel Cilk Clojure COBOL CoffeeScript ColdFusion Cool Coq D Dart DB2 Delphi / Pascal DTrace Elasticsearch Emacs Erlang F#

Github上的1000多本免费电子书重磅来袭!

这个GIthub库的免费电子书资源绝对值得你拥有,赶紧收藏吧! 以前 StackOverFlow 也给出了一个免费电子书列表,现在在Github上可以看到时刻保持更新的列表了. 瞥一眼下面的书籍分类目录,你就能知道这个免费电子书库的含金量了吧.记得一定要看几本,千万别下载了大量书籍而束之高阁! 行动重于空想! Github地址:     https://github.com/vhf/free-programming-books/blob/master/free-programming-books

GitHub限制上传大于100M的单个大文件

工作中遇到这个问题,一些美术资源..unitypackage文件大于100M,Push到GitHub时被拒绝.意思是Push到GitHub的每个文件的大小都要求小于100M. 搜了一下,很多解决办法只是把这些超过100M的大文件从本地版本库中移除,使得Push可以成功.但这并没有解决如何上传大文件到GitHub的问题. 解决办法是使用Git LFS. 用法参考:http://blog.csdn.net/tyro_java/article/details/53440666 按照以上方法设置好后,就

git 把本地创建的项目放到github上

很早之前就注册了Github,但对其使用一直懵懵懂懂,很不熟练.直到昨天做完百度前端技术学院的task,想把代码托管到Github上的时候发现自己对于Git的操作是如此之愚钝,所以今天决定把Git好好学习一遍,好让自己以后能更好地使用Github,主要还是通过Git教程 - 廖雪峰的官方网站来学习.简要步骤可以直接看最后的总结. Git的安装就不说了. 第一步:我们需要先创建一个本地的版本库(其实也就是一个文件夹). 你可以直接右击新建文件夹,也可以右击打开Git bash命令行窗口通过命令来创

如何上传代码到github?

如何上传代码到github? 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具,这里给出下载地址,下载后一路直接安装即可: https://git-for-windows.github.io/ 1.进入Github首页,点击New repository新建一个项目  2.填写相应信息后点击create即可 Repository name: 仓库名称 Description(可选): 仓库描述介绍 Public,