github入门及日常使用操作命令(附两个错误及解决办法)
2012-10-15 22:13
621 查看
What's git & git·hub?
开发环境:Linux,git工具1. 注册个帐号先。2.生成个SSH再(官网很详细,step-by-step)3. 创建个Repository(用来放项目的仓库)再。先在github上创建并写好相关名字,描述之后再在本地创建与之发生“联系”的文件夹。$cd ~ $mkdir github_JFF-RTOS //本地目录名与repository的名字不一定相同,相关即可 $cd ~/github_JFF-RTOS //进入github_JFF-RTOS目录复制所要托管的代码到此处:如果你选中了第3步的4,则你需要先执行
$git pull origin master
From github.com:mintist/JFF-RTOS * branch master -> FETCH_HEAD Merge made by the 'recursive' strategy. .gitignore | 12 ++++++++++++ README.md | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 .gitignore create mode 100644 README.md注意:那就是github自动帮你生成的两个文件,先拉(pull)下来先~~~否则~~~也没事,往后走先~~~
$git init //初始化
Initialized empty Git repository in /home/mintist/github_JFF-RTOS/.git/$git add . //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具体文件,见下文)$git commit -m "好吧,这还算不上一个RTOS~~~" //提交到本地仓库,然后会填写更新日志
4 files changed, 259 insertions(+) create mode 100644 Readme create mode 100644 app.c create mode 100644 core.c create mode 100644 core.h
$git remote add origin git@github.com:mintist/JFF-RTOS.git //增加到remote
$git push origin master //推(push)到github上if(yougit pull origin master as I say ,you will get )
Counting objects: 9, done.
Delta compression using up to 4 threads.Compressing objects: 100% (8/8), done.Writing objects: 100% (8/8), 2.96 KiB, done.Total 8 (delta 1), reused 0 (delta 0)To git@github.com:mintist/JFF-RTOS.git c13a550..109de37 master -> masterelse
To git@github.com:mintist/JFF-RTOS.git
! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'git@github.com:mintist/JFF-RTOS.git'To prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes (e.g. 'git pull') before pushing again. See the'Note about fast-forwards' section of 'git push --help' for details.如果遇到错误,再拉一下就好了~~还有平常的一些更新啥的请看下文,亲测可用~~~总结一下ubuntu下github常用的命令,设置部分跳过,假设repository的名字叫hello-world: 1.创建一个新的repository:先在github上创建并写好相关名字,描述。$cd ~/hello-world //到hello-world目录,本地目录名与repository的名字不一定相同$git init //初始化$git add . //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具体文件,见下文)$git commit //提交到本地仓库,然后会填写更新日志( -m “更新日志”也可,如$git commit -m “my first vesion of ...”)$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 //提交到本地仓库,不加参数会提示,注意:^=Ctrl,按照提示来就好了~~~$git push origin master //不是新创建的,不用再add 到remote上了3.更新项目(没新加文件,只有删除或者修改文件):$cd ~/hello-world$git commit -a //记录删除或修改了哪些文件$git push origin master //提交到github4.忽略一些文件,比如*.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 reset7.删除$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 上去。//------------------------------------------------------------------------------一个中文git手册:http://progit.org/book/zh/http://hi.baidu.com/wade_hit/item/848869db05e53af4cb0c391b
相关文章推荐
- github入门教程及日常使用操作命令
- Access中"操作必须使用一个可更新的查询"错误的解决办法
- 使用git commit命令时遇到 fatal: Unable to create index.lock File exists 错误的解决办法
- npm使用过程中的一些错误解决办法及npm常用命令
- 使用apache mail发送邮件两个常见的错误的解决办法
- 搜索功不能使用,出现“意外错误”操作无法完成?(完美解决办法)
- 使用LinqDataSource出现“找不到与ViewState中存储的原始值中的给定键相匹配的行,请确保"keys"字典包含与上一个Select操作返回的行对应的唯一键值”错误的解决办法
- npm使用过程中的一些错误解决办法及npm常用命令
- github常见操作和常见错误及其解决办法
- asp:(0X80004005)操作必须使用一个可更新的查询”错误的解决办法
- 错误“操作必须使用一个可更新的查询”原因及解决办法
- 环境变量设置错误导致全部命令无法使用解决办法
- 使用git命令提交远程github仓库的时候提示"rejected"(拒绝)解决办法
- 在linux上使用"scp"命令拷贝一个目录到另一台服务器的时候报"not a regular file"错误的解决办法
- 错误“操作必须使用一个可更新的查询”原因及解决办法
- Access中"操作必须使用一个可更新的查询"错误的解决办法
- 错误“操作必须使用一个可更新的查询”原因及解决办法
- npm使用过程中的一些错误解决办法及npm常用命令
- 使用yum命令安装软件时出现HTTP Error 404 NOT FOUND错误的解决办法
- 错误“操作必须使用一个可更新的查询”原因及解决办法