最近在用Git,查了点相关资料,逻辑依然不太明了,先整理一部分备忘,以后补充

一、本地Git与Github/码云的关联

1. 设置本地用户名,邮箱

git config --global user.name "用户名"
git config --global user.email "邮箱"

2. 生成SSH Key

1. ssh-keygen -t rsa -C "邮箱"
2. clip < ~/.ssh/id_rsa.pub //复制SSH Key到剪切板

3. 到Github或码云中添加上一步生成的SSH Key

4. 测试连接

github ssh -T git@github.com   //github
ssh -T git@git.oschina.net //码云(oschina)
ssh -T git@git.coding.net //码市(coding)

二、将本地的项目上传到github/码云的一般流程

0. 先在码云/github建个空仓储

1. git init

2. git remote add origin 你复制的地址

3. git pull origin master

4. git add .

5. git commit -m "提交信息"

6. git push -u origin master

参考: https://www.cnblogs.com/guaguaerhao/p/7865034.html

  1. 码云上创建一个项目 testgit (名字随你)
  2. 本地创建一个文件夹D:/testgit,然后使用git bash
  3. cd 到本地文件夹中D:/testgit,
  4. 使用 git init 命令 ,初始化一个git 本地仓库(项目),会在本地创建一个 .git 的文件夹
  5. 使用git remote add origin https://gitee.com/你的码云用户名/testgit //添加远程仓库
  6. 使用 git pull origin master 命令,将码云上的仓库pull到本地文件夹
  7. 将要上传的文件,添加到刚刚创建的文件夹
  8. 使用git add . 或者 git add + 文件名 (将文件保存到缓存区)
  9. 使用git commit -m '描述新添加的文件内容' (就是注释) (文件保存到本地仓库)
  10. 使用git push origin master ,将本地仓库推送到远程仓库

三、拉取远程项目到本地

1. 新建项目文件夹
2. 文件夹内打开Git bash
3. git init
4. git clone 项目地址

四、其他命令

git log
git status

git pull 失败 ,提示:fatal: refusing to merge unrelated histories

git pull origin master --allow-unrelated-histories

Git命令备忘的更多相关文章

  1. git 命令备忘

    git 常用命令备忘 仅作为日常使用备忘,并非常用命名整理 删除源端分支 git push orgin --delete branch_a a分支某次提交应用到b分支 切换到branch_b 分支: ...

  2. 偶尔要用的git命令备忘

    文档:https://git-scm.com/docs 列出所有远程空间: git remote -v 重命名远程空间: git remote rename <old> <new&g ...

  3. metasploit 常用命令备忘

    metasploit 常用命令备忘    MSFconsole Commands-------------------------------------24show exploits 查看所有exp ...

  4. git使用备忘

    简单的记录下现在使用git的时候,暂时或者常用到的命令,纯粹自己备忘,没用到过的命令就不写了,日后有用到了在补充. 1.把远程仓库克隆到本地:git clone 远程地址 2.分支操作 新建分支:gi ...

  5. Vi命令备忘

    备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...

  6. 实用Shell命令备忘

    开场白:这里简单记录一些常用的bash命令,一则备忘,二来希望可以帮助别人解决一些问题. 1.检测文件是否存在 if [ -f ./foo.txt ] then echo the file exist ...

  7. 常用linux命令备忘

    备忘: 关闭防火墙:# systemctl stop firewalld 查看防火墙状态:#  systemctl status firewalld 停止防火墙:#  systemctl disabl ...

  8. Git学习备忘

    本文参考廖雪峰写的精彩的git学习文档,大家可以直接去官网看原版,我这里只是便于自己记录梳理 原版地址:http://www.liaoxuefeng.com/wiki/0013739516305929 ...

  9. GIT常用命令备忘

    Git配置 git config --global user.name "storm" git config --global user.email "stormzhan ...

随机推荐

  1. [Swift]LeetCode475. 供暖器 | Heaters

    Winter is coming! Your first job during the contest is to design a standard heater with fixed warm r ...

  2. [Swift]LeetCode478. 在圆内随机生成点 | Generate Random Point in a Circle

    Given the radius and x-y positions of the center of a circle, write a function randPoint which gener ...

  3. [Swift]LeetCode675. 为高尔夫比赛砍树 | Cut Off Trees for Golf Event

    You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-nega ...

  4. PHP实现登录注册

    一.首先实现一个PHP的简单登录注册的话 我们要简单的与后端定义一下接口和传输数据的方式 并且我们要有一个phpStudy服务器. 第一步:当我们点击注册按钮的时候数据库要接收到客户端请求的数据  第 ...

  5. 使用xUnit为.net core程序进行单元测试 -- Assert

    第一部分: http://www.cnblogs.com/cgzl/p/8283610.html Assert Assert做什么?Assert基于代码的返回值.对象的最终状态.事件是否发生等情况来评 ...

  6. WARNING: 'aclocal-1.14' is missing on your system.

    源码安装zabbix agent时进行到make install时报如下错误: WARNING: 'aclocal-1.14' is missing on your system. You shoul ...

  7. oracle 12C利用dbca建库13步

    oracle用户登录然后命令行执行:dbca 如果没有此命令可以用:find / -name "dbca"查到后执行. 1.选择Create a database 2.选择Adva ...

  8. Spring Security构建Rest服务-1300-Spring Security OAuth开发APP认证框架之JWT实现单点登录

    基于JWT实现SSO 在淘宝( https://www.taobao.com )上点击登录,已经跳到了 https://login.taobao.com,这是又一个服务器.只要在淘宝登录了,就能直接访 ...

  9. WebSocket刨根问底(一)

    年初的时候,写过两篇博客介绍在Spring Boot中如何使用WebSocket发送消息[在Spring Boot框架下使用WebSocket实现消息推送][在Spring Boot框架下使用WebS ...

  10. 你安装的是SUN/Oracle JDK还是OpenJDK?

    目录 1 如何查看你安装的JDK版本 1.1 要用到的命令行工具 1.2 查看JDK的版本 2 什么是 OpenJDK 2.1 OpenJDK 的来历 2.2 Oracle JDK的来历 3 Orac ...