git杂记
来源:互联网 发布:python 爬虫 百科 编辑:程序博客网 时间:2024/05/21 22:00
echo "# fluke" >> README.md
git initgit add README.mdgit commit -m "first commit"git remote add origin git@github.com:username/xxx.gitgit push -u origin master
设置Git的user name和email:
git config --global user.name "xxx"
git config --global user.email "xxx@xxxx.com"
//----------------------------------------------------------------------------------------------------------------------------------------------------------
1.获取源码:
git clone git@github.com:billyanyteen/github-services.git
2.这样你的机器上就有一个repo了。
3.git于svn所不同的是git是分布式的,没有服务器概念。所有的人的机器上都有一个repo,每次提交都是给自己机器的repo
仓库初始化:
git init
生成快照并存入项目索引:
git add
文件,还有git rm,git mv等等…
项目索引提交:
git commit
4.协作编程:
将本地repo于远程的origin的repo合并,
推送本地更新到远程:
git push origin master
更新远程更新到本地:
git pull origin master
补充:
添加远端repo:
git remote add upstream git://github.com/pjhyett/github-services.git
重命名远端repo:
git://github.com/pjhyett/github-services.git为“upstream”
</pre><pre code_snippet_id="414065" snippet_file_name="blog_20140702_10_2996331" class=" bash" name="code" style="white-space: pre-wrap; word-wrap: break-word; color: rgb(34, 34, 34); font-size: 0.875em; line-height: 1.62; margin-top: 0.625em; margin-bottom: 0.625em; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"><span style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);">生成一个新的SSH。</span><br style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);" /><span style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);">ssh-keygen -t rsa -C "email"</span><br style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);" /><span style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);">之后直接回车,不用填写东西。之后会让你输入密码。然后就生成一个目录.ssh ,里面有两个文件:id_rsa , id_rsa.pub</span><br style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);" /><span style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);">把这个SSH放到github上。</span><span style="color: rgb(73, 73, 73); font-family: 'Microsoft YaHei', 'Helvetica Neue', SimSun; font-size: 14px; line-height: 21px; background-color: rgb(193, 207, 208);">用公钥。先在GitHub上注册一个用户,然后进入account-setting ,把id_rsa.pub的内容复制进去就可以了。</span>
</pre><pre code_snippet_id="414065" snippet_file_name="blog_20140702_10_2996331" class=" bash" name="code" style="white-space: pre-wrap; word-wrap: break-word; color: rgb(34, 34, 34); font-size: 0.875em; line-height: 1.62; margin-top: 0.625em; margin-bottom: 0.625em; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;">
</pre><pre code_snippet_id="414065" snippet_file_name="blog_20140702_10_2996331" class=" bash" name="code" style="white-space: pre-wrap; word-wrap: break-word; font-size: 0.875em; line-height: 1.62; margin-top: 0.625em; margin-bottom: 0.625em; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"><p style="color: rgb(51, 51, 51); margin-top: 0px; margin-bottom: 0.75em; font-size: 16px; line-height: 27.2000007629395px; text-indent: 1em; font-family: 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; background-color: rgb(254, 254, 254);">如果使用git远程推送时出现如下问题:</p><pre class="prettyprint perl" style="color: rgb(51, 51, 51); padding: 0.3em; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; border-radius: 4px; margin-top: 0px; margin-bottom: 1.5em; line-height: 1.5em; word-break: break-all; word-wrap: break-word; white-space: pre-wrap; border: 1px solid rgba(0, 0, 0, 0.14902); border-image-source: initial; border-image-slice: initial; border-image-width: initial; border-image-outset: initial; border-image-repeat: initial; overflow-y: auto; background-color: rgb(246, 246, 246);">git <span class="keyword" style="font-weight: bold;">push</span> -u origin master ssh: <span class="keyword" style="font-weight: bold;">connect</span> to host github.com port <span class="number" style="color: rgb(0, 153, 153);">22</span>: Connection refusedfatal: Could <span class="keyword" style="font-weight: bold;">not</span> <span class="keyword" style="font-weight: bold;">read</span> from remote repository.Please make sure you have the correct access rights<span class="keyword" style="font-weight: bold;">and</span> the repository <span class="keyword" style="font-weight: bold;">exists</span>.
可以采用如下方法:
vim .ssh/configHost github.comUser email@xxx.comHostname ssh.github.comPreferredAuthentications publickeyIdentityFile ~/.ssh/id_rsaPort 443
测试连接是否成功:
ssh -T git@github.comHi xxx! You've successfully authenticated, but GitHub does not provide shell access.
</pre><pre code_snippet_id="414065" snippet_file_name="blog_20140702_10_2996331" class=" bash" name="code" style="white-space: pre-wrap; word-wrap: break-word; color: rgb(34, 34, 34); font-size: 0.875em; line-height: 1.62; margin-top: 0.625em; margin-bottom: 0.625em; padding: 0px; border: 0px; outline: 0px; vertical-align: baseline; background-color: transparent;"><pre class="copyable-terminal-content js-zeroclipboard-target" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin-top: 0px; margin-bottom: 0px; font-stretch: normal; color: rgb(51, 51, 51);">
0 0
- git杂记
- git杂记
- Git杂记
- git杂记
- git杂记
- git杂记
- git实战杂记
- Git 使用杂记
- Git使用杂记
- git操作杂记
- adb-git-smb杂记
- GIT知识杂记
- git杂记:撤销
- git杂记:忽略ssl认证
- Linux git使用方法杂记(持续更新...)
- git杂记:如何避免每次输入密码
- 杂记
- 杂记
- iOS--通过URL获取图片
- C++ Primer 学习笔记——函数(一)
- mysql问题之infomation_schema
- Java NIO系列教程(二) Channel
- K-近邻算法之Python实现
- git杂记
- Lec 15 Projections onto subspaces
- Java NIO系列教程(三) Buffer
- 黑马程序员_java如何获取一个类(包括接口和抽象类)的对象
- Vi编辑器操作
- 字符分割算法研究
- 沈大海Bootstrap系列教程
- 在IOS下xcode使用github管理代码
- CentOS7 关闭防火墙