github如何更改别人的代码并上传

1.首先在github上找到你需要的代码,然后fork下来到你的github,点击你的项目,然后点击绿色的按钮Clone or download ,记录项目的地址 ,例如:https://github.com/li-lili/qingstor-sdk-c-and-cpp-1.git。

2.打开终端,使用git clone +你的项目地址 例如:git clone https://github.com/li-lili/qingstor-sdk-c-and-cpp-1.git,这样项目就从你的github上拷贝到了当前目录本地下,你可以对项目进行各种操作。

root@yunify-ThinkPad-T460:~/Desktop# git clone https://github.com/li-lili/qingstor-sdk-c-and-cpp-1.git
正克隆到 'qingstor-sdk-c-and-cpp-1'...
remote: Counting objects: 238, done.
remote: Compressing objects: 100% (174/174), done.
remote: Total 238 (delta 60), reused 233 (delta 58), pack-reused 0
接收对象中: 100% (238/238), 286.92 KiB | 177.00 KiB/s, 完成.
处理 delta 中: 100% (60/60), 完成.
检查连接... 完成。
root@yunify-ThinkPad-T460:~/Desktop# 

3.当你修改完你的项目,下一步需要上传到你的github上,在上传之前可以先检查一下你的改动是否成功了,在终端上git status一下就可以看到你的改动,例如:我新增加了一个1.c文件

root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# git status
位于分支 master
您的分支与上游分支 'origin/master' 一致。
未跟踪的文件:
  (使用 "git add <文件>..." 以包含要提交的内容)

	1.c

提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)
root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# 
4. 使用git add .   将当前工作目录中更改或者新增的文件加入到Git的索引中,加入到Git的索引中就表示记入了版本历史中,这也是提交之前所需要执行的一步,下一步,提交当前工作目录的修改内容,直接调用git commit命令,会提示填写注释。通过如下方式在命令行就填写提交注释:git commit -m "注释内容"。
root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# git add .
root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# git commit -m "add 1.c"
[master 9ee108d] add 1.c
 1 file changed, 1 insertion(+)
 create mode 100644 1.c
root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# 

5.上传代码至远程服务器  git push origin master,中途会要求输入用户名,密码。

root@yunify-ThinkPad-T460:~/Desktop/qingstor-sdk-c-and-cpp-1# git push --set-upstream origin master
Username for 'https://github.com': li-lili
Password for 'https://li-lili@github.com': 
对象计数中: 3, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (2/2), 完成.
写入对象中: 100% (3/3), 263 bytes | 0 bytes/s, 完成.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/li-lili/qingstor-sdk-c-and-cpp-1.git
   0031066..9ee108d  master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。

6.合并代码到作者,点击你的项目中new pull request,按照步骤合并

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值