Git_init

本地仓库管理:

使用 git init 初始化一个Git仓库。 
添加文件到 Git 仓库:

  1. 使用 git add <file> ,把工作区的文件修改添加到暂存区。
  2. 使用 git commit -m '...',把暂存区的所有内容提交到当前分支。

需要提交的文件修改通通放到暂存区,然后,一次性提交暂存区的所有修改。查看工作区状态:git status 命令。 如果git status 告诉你有文件被修改过,用git diff查看被修改的内容。

关联远程仓库:

  1. 如果仓库已存在,则跳过这一步,不然需要在GitHub上先创建这个远程仓库。
  2. 关联一个远程仓库: git remote add origin git@server-name:path/repo-name.git;
  3. 关联后,第一次使用 git push -u origin master推送本地仓库到远程仓库。以后使用 git push origin master 进行推送。
  4. 如果管理错了远程库,需要删除:git remote rm origin

 

"第一次修改 -> git add -> 第二次修改 -> git commit"

"你看,我们前面讲了,Git管理的是修改,当你用git add命令后,在工作区的第一次修改被放入暂存区,准备提交,但是,在工作区的第二次修改并没有放入暂存区,所以,git commit只负责把暂存区的修改提交了,也就是第一次的修改被提交了,第二次的修改不会被提交。提交后,用git diff HEAD -- readme.txt命令可以查看工作区和版本库里面最新版本的区别。"

先修改,再add这个修改到缓存区,再commit,这样版本库的代码就被修改了。如果没有add这个修改,那么commit时候不会提交这个修改,也就不会影响到版本库的代码。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Traceback (most recent call last): File "F:\conda\envs\yolov5\lib\site-packages\git\__init__.py", line 89, in <module> refresh() File "F:\conda\envs\yolov5\lib\site-packages\git\__init__.py", line 76, in refresh if not Git.refresh(path=path): File "F:\conda\envs\yolov5\lib\site-packages\git\cmd.py", line 392, in refresh raise ImportError(err) ImportError: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh() All git commands will error until this is rectified. This initial warning can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exception Example: export GIT_PYTHON_REFRESH=quiet The above exception was the direct cause of the following exception: Traceback (most recent call last): File "E:\yolov5-master\train.py", line 67, in <module> GIT_INFO = check_git_info() File "F:\conda\envs\yolov5\lib\contextlib.py", line 79, in inner return func(*args, **kwds) File "E:\yolov5-master\utils\general.py", line 360, in check_git_info import git File "F:\conda\envs\yolov5\lib\site-packages\git\__init__.py", line 91, in <module> raise ImportError("Failed to initialize: {0}".format(exc)) from exc ImportError: Failed to initialize: Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $GIT_PYTHON_GIT_EXECUTABLE - explicitly set via git.refresh() All git commands will error until this is rectified. This initial warning can be silenced or aggravated in the future by setting the $GIT_PYTHON_REFRESH environment variable. Use one of the following values: - quiet|q|silence|s|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exception Example: export GIT_PYTHON_REFRESH=quiet
最新发布
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值