当前位置:   article > 正文

【三】Git创建仓库

git创建仓库

目录

1.git init

2.git clone

3.设置

4.git的查增删改指令


1.git init

Git 使用 git init 命令来初始化一个 Git 仓库,Git 的很多命令都需要在 Git 的仓库中运行,所以 git init 是使用 Git 的第一个命令。

在执行完成 git init 命令后,Git 仓库会生成一个 .git 目录,该目录包含了资源的所有元数据,其他的项目目录保持不变。

git init newrepo//使用指定目录newrepo作为存放地

若当前目录内有其他内容需要合并进.git仓库中,使用代码:

  1. $ git add *.c
  2. $ git add README
  3. $ git commit -m '初始化项目版本

将 .c 结尾及 README 文件提交到仓库中

2.git clone

从已有的git仓库中copy项目:

  1. git clone <repo>//repo为git仓库
  2. //以下等价于以上
  3. git clone http://github.com/CosmosHua/locate new
  4. git clone http://github.com/CosmosHua/locate.git new
  5. git clone git://github.com/CosmosHua/locate new
  6. git clone git://github.com/CosmosHua/locate.git new
  7. //还可使用不同协议
  8. git clone git@github.com:fsliurujie/test.git --SSH协议【最快、常用】
  9. git clone git://github.com/fsliurujie/test.git --GIT协议
  10. git clone https://github.com/fsliurujie/test.git --HTTPS协议

copy到指定目录:

git clone <repo> <directory>//directory为本地目录

3.设置

显示当前git配置

  1. $ git config --list
  2. credential.helper=osxkeychain
  3. core.repositoryformatversion=0
  4. core.filemode=true
  5. core.bare=false
  6. core.logallrefupdates=true
  7. core.ignorecase=true
  8. core.precomposeunicode=true

编辑git的配置文件

  1. $ git config -e//针对当前仓库
  2. $ git config -e --global//针对系统上所有仓库

PS:推出编辑模式回到命令行的几种方法

1.保存并退出:

(1)按 Esc 键退出编辑模式,英文模式下输入 :wq ,然后回车(write and quit)。

(2)按 Esc 键退出编辑模式,大写英文模式下输入 ZZ ,然后回车。

2.不保存退出:
  按 Esc 键退出编辑模式,英文模式下输入 :q! ,然后回车。

  按 Esc 键退出编辑模式,英文模式下输入 :qa! ,然后回车。

设置提交代码时的用户信息

  1. $ git config --global user.name "runoob"
  2. $ git config --global user.email test@runoob.com

4.git的查增删改指令

  1. //查
  2. git config --global --list
  3. git config --global user.name
  4. git config --global user.email
  5. //增
  6. git config --global --add user.name xxx
  7. git config --global --add user.email xxx
  8. //删
  9. git config --global --unset user.name xxx
  10. git config --global --unset user.email xxx
  11. //改
  12. git config --global user.name xxx
  13. git config --global user.email xxx
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/940657
推荐阅读
相关标签
  

闽ICP备14008679号