最近在用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]LeetCode330. 按要求补齐数组 | Patching Array

    Given a sorted positive integer array nums and an integer n, add/patch elements to the array such th ...

  2. [Swift]LeetCode779. 第K个语法符号 | K-th Symbol in Grammar

    On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace ...

  3. [Swift]LeetCode891. 子序列宽度之和 | Sum of Subsequence Widths

    Given an array of integers A, consider all non-empty subsequences of A. For any sequence S, let the  ...

  4. [Swift]LeetCode1028. 从先序遍历还原二叉树 | Recover a Tree From Preorder Traversal

    We run a preorder depth first search on the root of a binary tree. At each node in this traversal, w ...

  5. Python文本数据互相转换(pandas and win32com)

    (工作之后,就让自己的身心都去休息吧) 今天介绍一下文本数据的提取和转换,这里主要实例的转换为excel文件(.xlsx)转换world文件(.doc/docx),同时需要使用win32api,同py ...

  6. Python数据挖掘(爬虫强化)

    (我喜欢雨天,因为雨天我可以回到童年踩水花!哈!) 2018年 --7月--12日 : 多云又暴雨 T—T 前言 我要把爬虫的终极利器介绍一下,这个只要是我们肉眼能看到的,就算在源码中或者在json中 ...

  7. python判断两个文件是否相同

    此方法相当于 Linux 系统下的diff,或者是 git 下的 checkout 官方解释请看: https://docs.python.org/2/library/difflib.html #!/ ...

  8. 网络协议 2 - IP 是怎么来,又是怎么没的?

    了解完网络协议,我们会发现,网络通信的五层模型里,有两个很重要的概念:IP 地址和 MAC 地址. 那么 IP 地址是怎么来的,又是怎么没的?MAC 地址与 IP 地址又有什么区别? 这回答上面问题前 ...

  9. java代码之美(2)---Java8 Stream

    Stream 第一次看到Stream表达式就深深把我吸引,用它可以使你的代码更加整洁而且对集合的操作效率也会大大提高,如果你还没有用到java8的Stream特性,那就说明你确实out啦. 一.概述 ...

  10. JVM虚拟机(1)---常用JVM配置参数

    常用JVM配置参数 常用JVM配置参数主要有:Trace跟踪参数.堆的分配参数.栈的分配参数. 一.Trace跟踪参数 跟踪参数用于跟踪监控JVM,对于开发人员来讲用于JVM调优以及故障排查的. 1. ...