笔记:git常用命令
常规操作
# 初始化仓库git init# 克隆远程仓库git clone $url# 拉取git pull# 提交git push# 查看仓库文件变动状态git status# 查看文件变动git diff分支
# 查看所有分支git branch -a# 查看本地分支git branch# 拉取远程分支git checkout -b $local_branch origin/$remote_branch# 切换分支git checkout $local_branch工作区/暂存区
# 将文件添加到暂存区git add $file# 🌰 例子git add \*.java # 添加.java结尾的文件到暂存区# 将文件从暂存区放回工作区git restore --staged $file# 丢弃工作区的修改git restore $file# 类似 git restore --staged $filegit reset HEAD $file# 丢弃指定文件本地的修改git checkout $file储藏
# 储藏当前变动git stash# 查看储藏列表git stash list# 恢复最新的贮藏git stash apply# 恢复指定贮藏git stash apply $stash_name# 恢复最新储藏并清理贮藏git stash pop# 清理贮藏git stash drop $stash_name鉴权
# 当前仓库记住密码git config credential.helper store# 全局记住密码git config --global credential.helper store