Git常用命令

测试

git --version

用户名配置

# 配置用户名
git config --global user.name "gezeqi"
# 配置用户邮件
git config --global user.email "ge051799qi@gmail.com"
# 查看所有配置
git config --list

提交

# 提交单个或多个文件只需要依次列出,若提交所有更改则使用.即可
git add files
git commit -m "Some comments"

推送

# 推送本地提交到远程仓库的指定分支
git push origin master/main

代理配置

  • git-config.command
#!/bin/bash
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
  • git-unset.command
#!/bin/bash
git config --global --unset http.proxy
git config --global --unset https.proxy
  • brew.command
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
brew update

删除

# 删除最近1次提交记录
git reset --hard HEAD~1
# 删除历史记录需要强制推送,但注意会覆盖远程历史,同时会影响其他人
git push origin master --force

Git LFS

git lfs track "*.obj"

git add .gitattributes