Mac下Git安装及配置

Mac下:

1、下载git版本并安装

运行终端

  •    查看git版本:

bogon:~ yan$ git --version

git version 2.16.3

  •     配置gitconfig文件

   vim ~/.gitconfig

   点击i进入编辑模式

  bogon:~ yan$ vim ~/.gitconfig

[user]
        name=guanxy
        email=999999999@qq.com
[alias]
        co=checkout
        ci=commit
st=status
        pl=pull
        ps=push
        dt=difftool
        ca=commit -am
        b=branch
~                                                                               
-- INSERT --

  

Esc  :wq 退出编辑模式

可以输入git st 查看

/******Git 配置完成******************/

 

2、建立git项目

    在gitHub或者码云上新建账户,我这里是在码云上建的https://gitee.com/--新建项目

    点击项目--管理--部署公钥管理--公钥管理--添加部署公钥

bogon:~ yan$ ls -all

bogon:~ yan$ cd .ssh/

bogon:.ssh yan$ ls -al

bogon:.ssh yan$ cat id_rsa.pub   //查看生成的公钥,并复制ssh-keygen -t rsa -C "xxx@xmail.com"   //生成秘钥

ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
把公钥添加到https://gitee.com/profile/sshkeys        //添加个人公钥

bogon:~ yan$ mkdir ReactHappyMmallDoc     //本地新建一个文件夹

bogon:~ yan$ cd ReactHappyMmallDoc

bogon:ReactHappyMmallDoc yan$ ls

bogon:ReactHappyMmallDoc yan$ git clone 项目路径

//切换到项目路径,把本地项目关联到远程目录

 

bogon:ReactHappyMmallDoc yan$ lsReact_happymmal

bogon:ReactHappyMmallDoc yan$ cd React_happymmal
bogon:React_happymmal yan$ ls
README.md
bogon:React_happymmal yan$ ls -al

bogon:React_happymmal yan$ vim .gitignore   //添加一个gitignore来忽略一些我们不需要的东西

  

bogon:React_happymmal yan$ git st

bogon:React_happymmal yan$ git add .       //把gitignore提交到本地

bogon:React_happymmal yan$ git ca "initial"     //把gitignore提交到远程

bogon:React_happymmal yan$ git ps     //推送到远程

 

原文地址:https://www.cnblogs.com/cristina-guan/p/8834340.html