github说明

来源:互联网 发布:哪里有招新手淘宝主播 编辑:程序博客网 时间:2024/06/05 22:55
一.关于git中文帮助网站:http://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E5%8F%96%E5%BE%97%E9%A1%B9%E7%9B%AE%E7%9A%84-Git-%E4%BB%93%E5%BA%93电子书:https://progit2.s3.amazonaws.com/zh/2014-11-16-d449e/progit-zh.138.pdf 二.在github建立仓库的正确流程1.安装git及添加信息到github的ssh key安装Git-1.9.4-preview20140929.exessh-keygen -t rsa -C "winstongit@gmail.com"eval `ssh-agent -s`ssh-add ~/.ssh/id_rsa复制id_rsa.pub的内容到https://github.com/settings/sshssh -T git@github.com 验证ssh是否成功配置 配置用户信息:git config --global user.name "winstongit"git config --global user.email "winstongit@gmail.com" 2.在github服务器上建空仓库 3.克隆仓库并配置本地关联git clone https://github.com/winstongit/udacityapp.git udacodecd udacodegit remote add uda https://github.com/winstongit/udacityapp.gitgit config --global credential.helper wincred //保存密码,避免每次推送都输账户和密码 4.拉取远程仓库分支git clone https://github.com/winstongit/Sunshine.git testgit branch -agit fetch origin xxx:xxxgit checkout xxx(或者git fetch origin xxx然后git checkout -b origin xxx或git checkout origin xxx) 5.添加远程分支//git remote add uda https://github.com/winstongit/udacityapp.gitgit branch xxxgit checkout xxxgit rm -r *git add --all .git commit -m "this is for test"git push -u origin xxx 6.删除远程分支git remote add uda https://github.com/winstongit/udacityapp.gitgit branch -d -r origin/xxx只能删除本地的远程分支显示,目前还是从github网站删除分支方便. 7.修改远程远程分支的名称git branch -m -r origin/v1.01 origin/v1.02 8.复制的仓库做新库无法比较之前的分支代码git log --reverse newrepogit log --reverse masterIf you redo your commits on top of the original history, you should then be able to compare the branches.There are several different ways that you can redo your commits, includinggit rebase --ontogit cherry-pick 9.github代码对比低版本在前,高版本在后,并保证是2个分支是同1个commit。否则会出现There isn't anything to compare.gh-pages and v2.00-list-item are entirely different commit histories.  三.使用中遇到的问题问题1.生成的ssh秘钥找不到解决方法:在~/.ssh目录下 问题2.Could not open a connection to your authentication agent解决方法:eval `ssh-agent -s`ssh-add ~/.ssh/id_rsa 问题3.git clone git@github.com:winstongit/Sunshinework.git失败,报错The authenticity of host 'github.com (192.30.252.130)' can't be established.解决方法:修改仓库访问方式,ssh改https。git@github.com:winstongit/Sunshinework.git为https://github.com/winstongit/Sunshinework.git 问题4.fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.解决方法:github建立对应名称的仓库git push -u origin master 问题5.error: src refspec master does not match any.error: failed to push some refs to 'https://github.com/winstongit/Sunshinework.git'解决方法:没有添加远程仓库,导致无法推送成功git remote add origin git@github.com:winstongit/Sunshinework.git //连接远程github项目 问题6.fatal: remote origin already exists.解决方法:存在多个远程仓库的本地映射,删除远程仓库的本地origin映射git remote rm origin 问题7.You've successfully authenticated, but GitHub does not provide shell access.The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in Gemfile.解决方法:第一个警告没关系,不影响使用第二个警告是linux的代码结尾空格符和windows不同,要剔除这个警告使用如下命令git config core.autocrlf true 问题8.无法删除本地当前分支git branch -d lesson_v1.1问题:error: Cannot delete the branch 'lesson_v1.1' which you are currently on解决方法:必须先切换到其他分支,再删除lesson_v1.1的分支git checkout mastergit branch -d lesson_v1.1 问题9.无法删除带子文件的文件夹fatal: pathspec 'weathercastv1.0' did not match any filesgit rm -r weather2.0 fatal: pathspec 'weathercastv3.02' did not match any files解决方法:git rm -rf *无法删除文件夹,说明文件夹并没有加入git管理rm -rf weathercastv1.0 问题10.查看代码是否是最新版本解决方法:git log 显示提交的commit记录git status 查看代码和服务器的差别git diffgit --help 问题11.无法切换分支 error: Your local changes to the following files would be overwritten by checkou t:解决方法:git checkout -f master 问题12.不想提交所在分支的修改,希望清空分支或希望代码复位解决方法:删除所有:rm -rf * ; git add --all .清空 git reset --hard head^^(复位到本地仓库的最原始版本,跟服务器对应的版本内容可能不同,不大建议使用)如不是最新版本则 git pull. 问题13.无法开启模拟器解决方法:c盘空间严重不足,挪到e盘。修改androidstudio\bin\idea.propertiesidea.config.path=E:/androidlearn/androidstudio/.AndroidStudioBeta/configidea.system.path=E:/androidlearn/androidstudio/.AndroidStudioBeta/systemidea.plugins.path=E:/androidlearn/androidstudio/pluginsidea.log.path=E:/androidlearn/androidstudio/log 问题14.模拟器太慢,解决方法:如果使用androud studio没有用apple电脑或者win7会有点吃亏。特别是使用模拟器的话没有硬件加速会很慢,最好使用真机调试,减少系统的消耗。使用真机仿真。最新的模拟器插件是genymotion。功能很全,没测试过。adb connect 192.168.1.151adb remount 问题15.无法下载所有分支解决方法:没解决,只能单独下载对应的分支? 问题16.无法删除github远程分支,git branch -d -r origin/x1 origin/x2 origin/x3无法删除解决方法:github还需要手动删除对应的分支 问题17.修改了git ignore文件,无法正确checkout文件解决方法:最终使用google课程源码中的.gitignore文件,确认参数齐全。 问题18.fatal: Cannot update paths and switch to branch 'origin' at the same time.Did you intend to checkout '4.11-add-content-provider-to-contract' which can notbe resolved as commit?git fetch origin 4.11-add-content-provider-to-contract:4.11-add-content-provider-to-contract解决方法:不能使用git fetch origin origin/xxx
1 0
原创粉丝点击