【工具使用】git和码云

GIT 使用语句整理

码云平台帮助文档
Git教程-廖雪峰的官方网站

常用语句


  • git pull origin master 更新本地存储库
  • git add 文件名 添加到暂存区
  • git commit -m "备注" 提交修改
  • git commit --amend 修改已提交的message,进入文件编辑界面进行修改
  • git status 查看文件修改状态
  • git push origin master 提交本地到git

安装语句


  • git config --global user.name "your name"

  • git config --global user.email "email@example.com"
    定义你的名称和email确定你的身份,用global参数表示这台机器上所有的Git仓库都会使用这个配置。

  • mkdir 文件夹 新建文件夹

  • cd 文件夹 进入文件夹下

  • pwd 显示当前目录(window请确保目录中全为英文)

  • git init
    Initialized empty Git repository in /Users/michael/learngit/.git/
    告诉的新建了一个空的仓库,目录下多了.git文件,请不要动它。

码云关联


  • git init 在当前目录下创建本地仓库
  • git remote add origin "地址" 关联码云远程库,名称为origin,后面跟地址。
  • git remote -v 查看当前远程库信息
  • git remote rm origin 删除已有的远程库

换行符


  • CRLF ---》Windows-style 表示回车换行 " "
  • LF ---》Unix-style 表示句尾,只是用换行 " "
  • CR ---》Mac-style 表示只使用回车 " "

当使用不同操作系统时,涉及到换行符自动转换的问题,需要使用下面的语句:

  • 提交、检出时均不转换,保留原格式

  • git config --global core.autocrlf false

  • 提交时转换为LF 检出时不转换

  • git config --global core.autocrlf input

  • 提交时转换为LF 检出时转换为CRLF

  • git config --global core.autocrlf true

autocrlf:

  • true x->LF->CRLF
  • input x->LF->LF
  • false x->x->x
  • 允许提交包含混合换行符的文件

  • git config --global core.safecrlf false

  • 拒绝提交包含混合换行符的文件

  • git config --global core.safecrlf true

  • 提交包含混合换行符的文件时给出警告

  • git config --global core.safecrlf warn

git add xx命令

可将xx文件添加到暂存区,若有很多改动可采用以下批量添加:

  • git add -A 添加所有内容(git add --all的缩写)
  • git add . 添加新增、修改的文件,不包括删除的文件
  • git add -u 添加修改、删除的文件,不包括新增的文件(git add --update的缩写)
原文地址:https://www.cnblogs.com/qiuyueding/p/7839895.html