GitHub 简明教程(转)
GitHub 简明教程
---------------------------------------------------------------------------
Auther: Roy Zhu
Date: 2008-04-29
Doc: 实践果然出真知!今天下午花了五个小时,终于弄懂了GitHub的用法。开心!
---------------------------------------------------------------------------
以一个测试用的项目为例(git://github.com/royzhu/test.git)
转到你的工作目录
roy@ubuntu:~/$ cd workspace
创建、下载项目文件夹(不知道是不是该叫它“包”)
roy@ubuntu:~/workspace$ git clone git://github.com/royzhu/test.git
等待一段时间后,项目就下好了
roy@ubuntu:~/workspace$ ls -la
drwxr-xr-x 3 roy roy 4096 2008-04-29 17:10 test
roy@ubuntu:~/workspace$ cd test
查看主枝和分支。登录GitHub.com,加入项目后,在项目里的Network有图形化的分支图
roy@ubuntu:~/workspace/test$ git show-branch
[master] a new branch
master是默认的住分支名
建立项目远程地址
roy@ubuntu:~/workspace/test$ git remote add origin git@github.com:royzhu/test.git
建立自己的分支
roy@ubuntu:~/workspace/test$ git branch your_branch_name
再看看有哪些分支
roy@ubuntu:~/workspace/test$ git show-branch
! [your_branch_name] a new branch
--
*+ [master] a new branch
查看现在使用的分支
roy@ubuntu:~/workspace/test$ git branch
* master
your_branch_name
加*号表示当前使用的分支
进入自己的分支
roy@ubuntu:~/workspace/test$ git checkout your_branch_name
再看看
roy@ubuntu:~/workspace/test$ git branch
master
* your_branch_name
添加、修改些东西吧
roy@ubuntu:~/workspace/test$ vim something
把文件加入跟踪(每次提交前必须写这步)
roy@ubuntu:~/workspace/test$ git add something
提交修改(提交到本地,没有传到服务器)
roy@ubuntu:~/workspace/test$ git commit -m '说明'
提交分支到服务器
roy@ubuntu:~/workspace/test$ git push origin your_branch_name
“origin”是固定的
获得最新的项目文件(从服务器下载)
roy@ubuntu:~/workspace/test$ git pull git://github.com/royzhu/test.git
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述