1. Git 不常见的命令

1.1. 删除分支

  • 删除本地分支: git tag -d tag_name
  • 删除远程分支: git push origin :refs/tags/tag_name

1.2. 删除远程仓库的文件

  1. 预览要删除的文件
git rm -r -n --cached 文件/文件夹名称

加上 -n 这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
  1. 确认删除文件
git rm -r --cached 文件/文件夹名称
  1. 提交本地并推送到远程服务器
git commit -m "提交说明"
git push origin master
  1. 修改本地 .gitignore 文件 并提交
git commit -m "提交说明"
git push origin master
  1. 查看 git 设置的用户名和邮箱地址
git config user.name
git config user.email
  1. 设置 git 用户名和邮箱
git config --global user.name "username"
git config --global user.email "email"
  1. clone 到一个非空目录
1. 进入非空目录,假设是 /workdir/proj1

2. git clone --no-checkout https://git.oschina.net/NextApp/platform.git tmp

3. mv tmp/.git .   #将 tmp 目录下的 .git 目录移到当前目录

4. rmdir tmp

5. git reset --hard HEAD
  1. 拉取远程分支到本地
git checkout -b 本地分支名x origin/远程分支名x
  1. 设置大小写敏感

shell script git config core.ignorecase false

results matching ""

    No results matching ""