将已有项目代码通过命令行方式上传到github,简易傻瓜教程(图文)将已有项目代码通过命令行方式上传到github,傻瓜教程(图文)1. 创建一个github项目2. 在Repository name

时间:2022-05-07
本文章向大家介绍将已有项目代码通过命令行方式上传到github,简易傻瓜教程(图文)将已有项目代码通过命令行方式上传到github,傻瓜教程(图文)1. 创建一个github项目2. 在Repository name,主要内容包括将已有项目代码通过命令行方式上传到github,傻瓜教程(图文)、1. 创建一个github项目、2. 在Repository name处填写项目的名字,并点击 Create Repository,如下图、3. 点击Clone or download,点击Copy to clipboard图标,如下图、4. 创建并切换到你的工作目录 我用的是~/Documents/2018code、5. 把创建好的项目克隆下来、6. 查看目录,并切换到新建目录、7. 将已有的项目copy到这个目录下面、8. 添加、提交、合并代码、9. 去github上查看新创建的文件已经上传上来了、10 . One more thing 我们再来一次,添加点好玩的、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。

将已有项目代码通过命令行方式上传到github,傻瓜教程(图文)

本文地址:http://www.jianshu.com/p/6030066a20e4 github地址:https://github.com/xy83918/CreateNewRepository 网页地址:https://xy83918.github.io/CreateNewRepository/

1. 创建一个github项目

打开www.github.com注册你自己的账号,登陆后点击右上角的 (+)按钮,然后点击new Repository,如下图所示

创建一个新的Repository

2. 在Repository name处填写项目的名字,并点击 Create Repository,如下图

填写Repository的名字.png

3. 点击Clone or download,点击Copy to clipboard图标,如下图

复制git地址.png

4. 创建并切换到你的工作目录 我用的是~/Documents/2018code

mkdir -p ~/Documents/2018code
cd ~/Documents/2018code

image.png

5. 把创建好的项目克隆下来

git clone https://github.com/xy83918/CreateNewRepository.git

image.png

6. 查看目录,并切换到新建目录

ls
cd CreateNewRepository/

image.png

image.png

7. 将已有的项目copy到这个目录下面

小技巧可以使用 open . 使用finder打开当前目录,然后把你想要添加的文件拖动到这个目录就可以了 open .

image.png

检查一下目录是否有改动

git status

image.png

创建一个文件

echo “# test” >> test.txt

image.png

再次检查一下目录是否有改动

git status

image.png

8. 添加、提交、合并代码

git add -A

git commit -m "add test.txt"

git push origin master

image.png

9. 去github上查看新创建的文件已经上传上来了

image.png

10 . One more thing 我们再来一次,添加点好玩的

image.png

贴出来方便大家粘贴

AlbertMP:CreateNewRepository Albert$ echo "这是一个网页" >> index.html
AlbertMP:CreateNewRepository Albert$ ls
README.md   index.html  test.txt
AlbertMP:CreateNewRepository Albert$ git add -A
AlbertMP:CreateNewRepository Albert$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   index.html

AlbertMP:CreateNewRepository Albert$ git commit -m "init"
[master 779e7e9] init
 1 file changed, 1 insertion(+)
 create mode 100644 index.html
AlbertMP:CreateNewRepository Albert$ git push origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 318 bytes | 318.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/xy83918/CreateNewRepository.git
   163303f..779e7e9  master -> master
AlbertMP:CreateNewRepository Albert$

将我们的静态网页发布

点击Settings

image.png

滚动到GitHub Pages

image.png

设置成和下图一样

image.png

点击链接,你的静态网站生成了

image.png

然后你就可以为所欲为了,想做什么静态网页都可以去修改这个html了。

https://xy83918.github.io/CreateNewRepository/