Git学习
2026-11-08
git -v 查看版本号
git config --global user.name "Anxun" --global全局配置所有仓库生效 --Local只对本仓库生效 --system对所有用户生效 用户名没有空格的时候可以不使用双引号
git cofig --global user.email anxunqixun@clouded.top
git cofig --global credential.helper store 记住用户名密码邮箱
git cofig --global --list 查看配置信息Repo repository仓库
git init 创建一个仓库 git init newflodername 新建立子目录创建新仓库
ls -a 查看隐藏目录 应该会有.git 目录存在
git clone https://xxx.com/xxx.git 克隆远程仓库到本地
工作区.git (git add)暂存区.git/index (git commit) 本地仓库 .git/objects
未跟踪 未修改 已修改 已暂存
git status 查看仓库状态
git add 添加到暂存区
git commit 提交
echo "new file" > xxx.xx
Untracked files:(未跟踪状态的文件)
xxx.xx
git add xxx.xx git add *.txt (txt结尾的文件全部添加到暂存区) git add . (全部提交到暂存区)
Changes to be commited:(添加到了暂存区)
new file: xxx.xx
git rm --cache <file>... to unstage
git commit -m "提交的描述" (只提交暂存区中的文件到仓库)git reset -- soft|hard|mixed 回退到某一个版本(保存工作区和暂存区的全部内容|丢弃工作区和暂存区的全部内容|保留工作区的修改内容,丢弃暂存区的修改内容[默认])
git ls-files 查看暂存区里面的内容
git rm <file> 从工作区和暂存区都删除文件(删除之后记得git commit) 单独删除工作区的文件之后需要 git add . 同步本次的工作区和暂存区之间的数据
git rm --cache <file> 把文件从暂存区删除,但保留在当前工作区的目录中
.gitignore