【工具使用】Git 软件


Git软件

1. 安装git软件(下一步直到完成)

官网下载地址:(https://git-scm.com/downloads)

2. 码云注册(保存代码)

Gitee官网地址:(https://gitee.com)
  • 注册

  • 创建代码托管新仓库

  • 类似创建一个文件夹

3. 设置自己的账号信息(第一次使用需要设置)

  1. 进入到提交代码的目录下:cd xx:\xx\xx... (自己需要提交代码的目录)

  2. 命令:

    git config --global user.name "你的名字或昵称"
    git config --global user.email "你的邮箱地址"
    

    然后执行:git config --global --list查看Git连接使用的账号和邮箱。

  3. 上传本地代码到远程仓库

    1. 在本地需要提交代码的目录下,右键选择:Git Bash Here(Windows)
      在终端cd进入到本地需要提交代码的目录下就可(macOS)

    2.  git init		# 初始化本地项目
       git add .		# 将当前目录所有文件添加到git暂存区
       git commit -m "注释的内容"	# 提交并备注提交信息
       git remote add origin https://gitee.com/用户个性地址/仓库名	# 关联远程仓库
       git push origin master		# 提交代码到远程仓库
      
    3. 在弹出账号和密码时:输入账号和密码即可

    4. 删除关联远程仓库

      # 查看远程库信息
      git remote -v
      git remote rm origin
      
  4. 将远程仓库克隆到本地

    git clone https://gitee.com/用户个性地址/仓库名
    
  5. 远程仓库同步最新版本到本地

    git pull origin master