总结一下ubuntu下github常用的命令,设置部分跳过,假设repository的名字叫hello-world:
1.创建一个新的repository:
先在github上创建并写好相关名字,描述。
$cd ~/hello-world //到hello-world目录
$git init //初始化
$git add . //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具体文件)
$git commit //提交到本地仓库,然后会填写更新日志( -m “更新日志”也可)
$git remote add origin git@github.com:WadeLeng/hello-world.git //增加到remote
$git push origin master //push到github上
2.更新项目(新加了文件):
$cd ~/hello-world
$git add . //这样可以自动判断新加了哪些文件,或者手动加入文件名字
$git commit //提交到本地仓库
$git push origin master //不是新创建的,不用再add 到remote上了
3.更新项目(没新加文件,只有删除或者修改文件):
$cd ~/hello-world
$git commit -a //记录删除或修改了哪些文件
$git push origin master //提交到github
4.忽略一些文件,比如*.o等:
$cd ~/hello-world
$vim .gitignore //把文件类型加入到.gitignore中,保存
然后就可以git add . 能自动过滤这种文件
5.clone代码到本地:
$git clone git@github.com:WadeLeng/hello-world.git
假如本地已经存在了代码,而仓库里有更新,把更改的合并到本地的项目:
$git fetch origin //获取远程更新
$git merge origin/master //把更新的内容合并到本地分支
6.撤销
$git reset
7.删除
$git rm * // 不是用rm
//——————————常见错误———————————–
1.$ git remote add origin git@github.com:WadeLeng/hello-world.git
错误提示:fatal: remote origin already exists.
解决办法:$ git remote rm origin
然后在执行:$ git remote add origin git@github.com:WadeLeng/hello-world.git 就不会报错误了
2. $ git push origin master
错误提示:error:failed to push som refs to
解决办法:$ git pull origin master //先把远程服务器github上面的文件拉先来,再push 上去。
//—————————————
[整理自网络]
分类目录
- arch/management (17)
- computer (38)
- java/j2ee (304)
- lnmpa (237)
- mac/iphone/ipad/android (11)
- mysql/oracle/postgresql (126)
- os/software (74)
- other (518)
- python (6)
- redis/memcached/mongo (31)
- sitebuild (143)
随便看看
标签云
程序员 创业 人生箴言 eclipse 快捷键 术语 索引 unix命令 vim wordpress java学习笔记 环境变量 oracle内置函数 index 人生 数据类型 nohup tuxedo mysql学习笔记 MS-DOS命令 servlet spring 职场进阶 职业进阶 服务器选购 服务器选型 apache JPA MongoDB 注解 tomcat 子女教育 jquery maven JVM aix命令 网络营销 java异常 seo 人生规划 关键字 css 网络推广 struts 系统优化 成长 frame iframe bluehost jdbc select 我的信仰 oracle函数 cookie HashMap 站长工具 乱码 ArrayList secureCRT jsp session tail find halt 事务 oracle单记录函数 算法 URL window table javascript操作表单元素 String 字符串处理 健康 http 域名 情感 more google A记录 域名解析 netstat 弹出对话框 弹出窗口 框架集 框架 excel 字符串 javascript函数 showModalDialog nginx number 数组 sql frameset 开源程序 java数组 软件 oracle服务友情链接
收藏链接