阿珏酱Blog因为我是活在二次元的女孩

Git简单的使用步骤

阿珏酱·2024-05-20 15:46·7 次阅读

Git简单的使用步骤

Tips:当你看到这个提示的时候,说明当前的文章是由原emlog博客系统搬迁至此的,文章发布时间已过于久远,编排和内容不一定完整,还请谅解`

Git简单的使用步骤

日期:2018-4-3 阿珏 教程 浏览:2117次 评论:0条

本文并不阐述任何概念性知识,仅仅只是做一个笔记,简单是使用步骤,如遇障碍,请Google一下

使用SSH 完成 Git 与 GitHub 的绑定#

  1. 生成

    SSH key
Copy
ssh-keygen -t rsa

指定 RSA 算法生成密钥,之后就就会生成两个文件,分别为id_rsa和id_rsa.pub,即密钥id_rsa和公钥id_rsa.pub. 对于这两个文件

  1. 添加

    SSH key

    github.com ->

    Settings ->

    SSH and GPG -> New SSH key
    将公钥id_rsa.pub的内容粘贴到Key处的位置(Titles的内容不填写也没事),然后点击Add SSH key 即可。

  2. 验证绑定是否成功

Copy
ssh -T git@github.com

把本地项目推送到github的命令#

(1) 打开你的目录

Copy
cd demo

(2) 初始化版本库,用于生成git文件

Copy
git init

(3) 将所有文件添加到缓存区

Copy
git add *

(4) 提交当前工作空间的修改内容

Copy
git commit -m "first commit"

(5) 将仓库连接到远程服务器

Copy
git remote add origin <server>(就是上面你仓库的地址)

(6) 将改动推送到所添加的服务器上

Copy
git push -u origin master

在推送的时候如果出现如下错误:#

Copy
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文件不在本地代码目录中。所以我们把上面第六步分成两步:

Copy
git pull --rebase origin master:进行代码合并
Copy
git push -u origin master
posted @   阿珏酱  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示
目录