初次在 GitHub 建立仓库以及公开代码的流程
来源:互联网 发布:生存模型 软件 编辑:程序博客网 时间:2024/04/28 11:07
初次在 GitHub 建立仓库以及公开代码的流程 - 公开代码
在已有仓库中添加代码并加以公开。1. clone 已有仓库
将已有仓库 clone 到身边的开发环境中。
strong@foreverstrong:~$ mkdir github_workstrong@foreverstrong:~$ cd github_work/strong@foreverstrong:~/github_work$ lltotal 8drwxrwxr-x 2 strong strong 4096 Dec 17 14:03 ./drwxr-xr-x 44 strong strong 4096 Dec 17 14:03 ../strong@foreverstrong:~/github_work$ git clone https://github.com/ForeverStrongCheng/Hello-World.gitCloning into 'Hello-World'...remote: Counting objects: 4, done.remote: Compressing objects: 100% (3/3), done.Unpacking objects: 100% (4/4), done.remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0Checking connectivity... done.strong@foreverstrong:~/github_work$ lltotal 12drwxrwxr-x 3 strong strong 4096 Dec 17 14:04 ./drwxr-xr-x 44 strong strong 4096 Dec 17 14:03 ../drwxrwxr-x 3 strong strong 4096 Dec 17 14:04 Hello-World/strong@foreverstrong:~/github_work$ cd Hello-World/strong@foreverstrong:~/github_work/Hello-World$ lltotal 20drwxrwxr-x 3 strong strong 4096 Dec 17 14:04 ./drwxrwxr-x 3 strong strong 4096 Dec 17 14:04 ../drwxrwxr-x 8 strong strong 4096 Dec 17 14:04 .git/-rw-rw-r-- 1 strong strong 272 Dec 17 14:04 .gitignore-rw-rw-r-- 1 strong strong 13 Dec 17 14:04 README.mdstrong@foreverstrong:~/github_work/Hello-World$
strong@foreverstrong:~/github_work/Hello-World$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit, working directory cleanstrong@foreverstrong:~/github_work/Hello-World$
将想要公开的代码提交至这个仓库再 push 到 GitHub 的仓库中,代码便会被公开。
2. 编写代码
由于 Hello_World.py 还没有添加至 Git 仓库,所以显示为 Untracked files。
strong@foreverstrong:~/github_work/Hello-World$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.Untracked files: (use "git add <file>..." to include in what will be committed)Hello_World.pyimage_data/nothing added to commit but untracked files present (use "git add" to track)strong@foreverstrong:~/github_work/Hello-World$
3. 提交
将 Hello_World.py 提交至仓库。这样一来,这个文件就进入了版本管理系统的管理之下。今后的更改管理都交由 Git 进行。
strong@foreverstrong:~/github_work/Hello-World$ git add .strong@foreverstrong:~/github_work/Hello-World$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.Changes to be committed: (use "git reset HEAD <file>..." to unstage)new file: Hello_World.pynew file: image_data/lena.jpgstrong@foreverstrong:~/github_work/Hello-World$ strong@foreverstrong:~/github_work/Hello-World$ git commit -m "Add Hello World script by Python"[master a984390] Add Hello World script by Python 2 files changed, 21 insertions(+) create mode 100644 Hello_World.py create mode 100644 image_data/lena.jpgstrong@foreverstrong:~/github_work/Hello-World$
通过 git add 命令将文件加入暂存区,再通过 git commit 命令提交。
添加成功后,可以通过 git log命令查看提交日志。
strong@foreverstrong:~/github_work/Hello-World$ git logcommit a984390cb3c6b756842675b0cd13f00a6c428e6bAuthor: chengyq116 <chengyq116@163.com>Date: Sun Dec 17 15:23:42 2017 +0800 Add Hello World script by Pythoncommit 8054468596d91cfedab242b08b3fa111d8d68aacAuthor: Yongqiang Cheng <chengyq116@163.com>Date: Sun Dec 17 13:17:11 2017 +0800 Initial commitstrong@foreverstrong:~/github_work/Hello-World$ strong@foreverstrong:~/github_work/Hello-World$ git statusOn branch masterYour branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)nothing to commit, working directory cleanstrong@foreverstrong:~/github_work/Hello-World$
4. 进行 push
之后只要执行 push, GitHub 上的仓库就会被更新,代码就在 GitHub 上公开了。
strong@foreverstrong:~/github_work/Hello-World$ git pushwarning: push.default is unset; its implicit value has changed inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the traditional behavior, use: git config --global push.default matchingTo squelch this message and adopt the new behavior now, use: git config --global push.default simpleWhen push.default is set to 'matching', git will push local branchesto the remote branches that already exist with the same name.Since Git 2.0, Git defaults to the more conservative 'simple'behavior, which only pushes the current branch to the correspondingremote branch that 'git pull' uses to update the current branch.See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' if you sometimes use older versions of Git)Username for 'https://github.com': chengyq116@163.comPassword for 'https://chengyq116@163.com@github.com': Counting objects: 5, done.Delta compression using up to 8 threads.Compressing objects: 100% (4/4), done.Writing objects: 100% (5/5), 90.25 KiB | 0 bytes/s, done.Total 5 (delta 0), reused 0 (delta 0)To https://github.com/ForeverStrongCheng/Hello-World.git 8054468..a984390 master -> masterstrong@foreverstrong:~/github_work/Hello-World$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit, working directory cleanstrong@foreverstrong:~/github_work/Hello-World$
references
(日) 大塚弘记 著, 支鹏浩, 刘斌 译. GitHub入门与实践[M]. 北京:人民邮电出版社, 2015. 1-255
阅读全文
0 0
- 初次在 GitHub 建立仓库以及公开代码的流程
- 初次在 GitHub 建立仓库以及公开代码的流程
- github视频教程-02 建立项目仓库以及代码上传
- github—本地建立与远端仓库的联系以及代码上传与合并
- MAC下使用GitHub建立属于自己的代码仓库
- Github:在Github上创建自己的代码仓库
- Github:在Github上创建自己的代码仓库
- git建立本地仓库、gitHub上传项目以及git和gitHub的关系
- 在PhpStorm中管理GitHub代码仓库的使用方法
- 在PhpStorm中管理GitHub代码仓库的使用方法
- github代码仓库的删除
- GitHub仓库的建立和删除
- github建立本地仓库
- github建立远程仓库
- 在GitHub上创建代码仓库
- 在GitHub上创建代码仓库
- 如何在github上创建代码仓库
- Eclipse在github上创建代码仓库
- 如何成为架构师?7 个关键的思考、习惯和经验
- Java Concurrency 3: 锁优化
- 《python参考手册(第四版)》【PDF】下载
- 【清华集训2017模拟12.10】回文串
- 新手用Eclipse IDE for C/C++ Developers开发环境搭建
- 初次在 GitHub 建立仓库以及公开代码的流程
- HDU 4280 Island Transport (ISPA)
- 2017.12.9 PAT乙级
- C++申请的数组,数组里的元素默认赋值竟然是很大的负数!
- Spring学习(1)--使用xml配置Bean属性
- linux线程同步(2)-条件变量
- c语言记录
- 2.4Ubuntu 12.04 LTS (Precise Pangolin)
- 637. Average of Levels in Binary Tree