git基本配置与使用

step1:第一步当然是从git官网下载git了,一路默认安装即可。

step2:配置个人信息

   git config --global user.name "Your Name"

   git config --global user.email [email protected]

    注意这里的--global,更改的配置文件位于用户主目录下,以后所有项目都会默认使用这里配置。如果要在某个特定的项目中使用其他配置,只要去掉 --global选项重新配置即可,新的设定保存在当前项目的 .git/config 文件里。(一般.git 默认都是隐藏的)

step3:

  (1)选择希望的文本编辑软件,假设文本编辑软件路径:H:/Program Files/Notepad++/Notepad++.exe  

  (2)打开gitbash,在该窗口中输入:

   git config --global core.editor="H:/'Program Files'/Notepad++/Notepad++.exe"

  or: git config --global core.editor  "H:/'Program Files'/Notepad++/Notepad++.exe"

        注意:'Program Files‘: 因为中间有空格,所以必须使用单引号括起来。

  (3)设置完毕,就可以调用git config --list查看配置了。

  (4) 因为配置中使用了--global参数,所以这种配置修改是对所有用户都有效。

      如果要删除默认的文本编辑软件,则在gitbash窗口输入如下命令即可,因为git可以指定多个文本编辑软件,所以删除配置也有两种方式:

               (1) git config --unset  --global core.editor   %删除整个配置文件

            or(2) git config --unset --global  core.editor="H:/'Program Files'/Notepad++/Notepad++.exe"    %仅删除相应内容的配置文件

step3:生成ssh秘钥。

  在C:\Users\Administrator目录下运行git bash。

        产生秘钥   ssh-keygen -t rsa -b 4096 -C "[email protected]"

  之后将id_rsa.pub 中的秘钥添加到git-hub中。利用 ssh -T [email protected] 检测是否能成功连接git-hub。

step4:从git-hub 上克隆仓库

  git clone git://github.com/schacon/grit.git

git add ./

git commit -m "first commit"

git push

Reference:

https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-%E5%88%9D%E6%AC%A1%E8%BF%90%E8%A1%8C-Git-%E5%89%8D%E7%9A%84%E9%85%8D%E7%BD%AE

https://blog.csdn.net/machinecat5888/article/details/73609966

猜你喜欢

转载自www.cnblogs.com/Zhang-Tx/p/9057995.html