Git简单的使用步骤
Tips:当你看到这个提示的时候,说明当前的文章是由原emlog博客系统搬迁至此的,文章发布时间已过于久远,编排和内容不一定完整,还请谅解`
Git简单的使用步骤
日期:2018-4-3 阿珏 教程 浏览:2117次 评论:0条
本文并不阐述任何概念性知识,仅仅只是做一个笔记,简单是使用步骤,如遇障碍,请Google一下
使用SSH 完成 Git 与 GitHub 的绑定#
- 生成
SSH key
ssh-keygen -t rsa
指定 RSA 算法生成密钥,之后就就会生成两个文件,分别为id_rsa和id_rsa.pub,即密钥id_rsa和公钥id_rsa.pub. 对于这两个文件
-
添加
SSH key
github.com ->
Settings ->
SSH and GPG -> New SSH key
将公钥id_rsa.pub的内容粘贴到Key处的位置(Titles的内容不填写也没事),然后点击Add SSH key 即可。 -
验证绑定是否成功
ssh -T git@github.com
把本地项目推送到github的命令#
(1) 打开你的目录
cd demo
(2) 初始化版本库,用于生成git文件
git init
(3) 将所有文件添加到缓存区
git add *
(4) 提交当前工作空间的修改内容
git commit -m "first commit"
(5) 将仓库连接到远程服务器
git remote add origin <server>(就是上面你仓库的地址)
(6) 将改动推送到所添加的服务器上
git push -u origin master
在推送的时候如果出现如下错误:#
warning: redirecting to https://github.com/178146582/dabai.git/
To http://github.com/178146582/dabai.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://github.com/178146582/dabai.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.
查了一下错误的原因是github中的README.md文件不在本地代码目录中。所以我们把上面第六步分成两步:
git pull --rebase origin master:进行代码合并
git push -u origin master
作者: 阿珏酱
出处:https://www.cnblogs.com/Ajue/p/18202103
本博客所有文章如无特别注明均为原创。本站使用「CC BY-NC-SA 4.0」创作共享协议,引用或转载请以超链接形式注明作者及出处。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义