向git提交代码及更新代码的命令
2015-08-24 10:25
387 查看
一、提交代码
(1)cd C:\Users\{{username}}\Desktop\{{filename}}说明:若项目文件夹路径为C:\Users\{{username}}\Desktop\{{filename}},则{{username}}为操作系统的用户名,{{filename}}是你要提交代码的项目文件夹;路径也可以是其他的
(2)git init
说明:这是初始化在{{filename}}文件夹中建立一个空库
(3)git add
说明:这条命令有两种用法:git add . (注意add和.之间有空格)用于把当前文件夹中的所有文件都加入到上传的列表中;git add "你要添加的文件(test.txt)"
(4)git commit -m "说明"
说明:这个"说明"可以自己随意写
(5)git remote add origin https://github.com/test/test.git
说明:origin 相当于是个别名 你可以不管它,也自己随便写或者写成当前文件夹名 , 后面的地址是你在github新建的仓库地址
(6)git push -u origin master
说明:此处的origin和(5)中的origin需保持一致。
注:
若执行第(6)步出现如下错误:
To https://github.com/test/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/test/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
则使用如下命令代替第(6)步:
git push -f origin master
二、更新代码
(1)cd C:\Users\{{username}}\Desktop\{{filename}}说明:若项目文件夹路径为C:\Users\{{username}}\Desktop\{{filename}},则{{username}}为操作系统的用户名,{{filename}}是你要提交代码的项目文件夹;路径也可以是其他的
(2)git add
说明:这条命令有两种用法:git add . (注意add和.之间有空格)用于把当前文件夹中的所有文件都加入到上传的列表中;git add "你要添加的文件(test.txt)"
(3)git commit -m "说明"
说明:这个"说明"可以自己随意写
(4)git push -u origin master
说明:origin这个别名就是你首次向github提交代码时用的别名
相关文章推荐
- JAVA 泛型方法 和 静态方法泛型
- Java枚举类
- Java中间件:淘宝网系统高性能利器(转)
- 【机房收费系统】VB中如何将数据导入excel2013
- struts2和servlet共存的几种方法
- C4D制作毛发舞动的Logo
- 启用windows 7自带FTP教程
- C++ 入门教程(一) 写C++前的准备
- synchronized用到不同地方对代码产生的影响
- Python自然语言处理学习笔记之选择正确的特征(错误分析 error analysis)
- 启动eclipse时Failed to load the JNI shared library
- STM32F4——独立看门狗与窗口看门狗
- 加了GO后报 'GO' 附近有语法错误
- 代码管理学习网址
- php SQL 防注入的一些经验
- Ubuntu下QTE的安装
- SWT_JFace_RCP学习相关网页
- 使用WinDbg获得托管方法的汇编代码
- java组合模式
- python 语言技巧特点