导入Git

作者: Mexplochin | 来源:发表于2018-12-01 11:09 被阅读0次
Windows下安装Git

在Windows环境中,导入Git较简单的方法是用msysGit,在其Setup程序中选择自己需要的组件,在Adjusting your PATH environment栏下,如无特殊需求,尽量选择Use Git Bash only,这会在以后使用Git时带来一定的方便,在Configuring the line ending conversions栏设置换行符转换时,选择Checkout Windows-style, commit Unix-style line ending,这样换行符在签出时会自动转换为CRLF,在提交时则会自动转换为LF。

初始化设置

设置使用Git时的姓名、邮箱(英文)并提高命令输出的可读性

$ git config --global user.name "yourName"
$ git config --global user.email "yourEmail@example.com"
$ git config --global color.ui auto

可使用cat ~/.gitconfig 命令抓取文件,查看设置内容

Github连接已有Git仓库

连接仓库的认证使用SSH公开密钥认证方式,所以需要创建这种认证方式所需的SSH Key,并将其添加到GitHub,SSH Key的创建如下,注意需要以管理员方式打开Git Bash

$ ssh-keygen -t  rsa -C"创建Github账户时用的邮箱"
Generating public/private rsa key pair
Enter file in which to save the key
(/Users/your_user_directory/.ssh/id_rsa):按回车键
Enter passphrase (empty for no passphrase):输入密码
Enter same passphrase again:再次输入密码

成功后会返回fingerprint值(也就是上面输入的邮箱)和密钥的random image,其中id_rsa是私有密钥,id_rsa.pub是公开密钥。
接下来需要在Github中添加公开密钥内容 Account Settings—>SSH Keys in menu—>Add SSH Key,可以在Git Bash中抓取id_rsa.pub文件查看公开密钥的内容,

$ cat  ~/.ssh/id_rsa.pub
ssh-rsa (这里会显示公开密钥的内容) yourEmail@example.com

可以使用查看ssh -T git@github.com是否连接成功,连接成功则会出现如下语句,

Hi userName! You've successfully authenticated, but GitHub does not provide shell access.
Git Bash辅助命令

除了Git命令外,一些Git Bash辅助命令也会给使用Git带来方便,这里列举几条:

  • 创建目录mkdir
  • 创建文件touch
  • 查看文件cat
  • 编辑文件vi
  • 目录进退cdcd ..(注意cd ..之间要空一格)

相关文章

  • 为as 配置 git

    as导入github项目 as提示没有git 下载 安装 Git as配置git

  • 【转】eclipse从git下载的maven项目需要转成mave

    导入git项目: 选择导入git项目有会有两个选项:一个是从本地git仓库中导入项目,一个是从github远程仓库...

  • 导入Git

    Windows下安装Git 在Windows环境中,导入Git较简单的方法是用msysGit,在其Setup程序中...

  • Linux 搭建Git服务器

    安装Git 创建 Git 用户 导入公钥 创建Git仓库 禁用git用户Shell 在 /etc/passwd 文...

  • idea

    一、工程导入 1、本地导入 2、在线导入 (1)用idea下载导入 (2)命令行操作导入 格式:Git clone...

  • SVN迁移Git

    参考:GIt - 迁移到Git 构建user.txt 关联svn用户和git用户。 用git svn导入svn库 ...

  • Git status add commit push pull

    Git 上传到远程分支 git status //可查看文件状态 git add . //将所有文件导入到缓存区 ...

  • GIT仓库导入

    通过命令行创建一个新的版本库 git initgit add xxx.xgit commit -m "first ...

  • QZPTool使用介绍

    导入 Podfile 里面添加pod ‘QZPTool’, :git => 'https://github.com...

  • 2021-11-11

    android studio 导入远程仓库步骤 vcs->git->clone

网友评论

      本文标题:导入Git

      本文链接:https://www.haomeiwen.com/subject/qaslcqtx.html