Git 常用操作及常见问题整理

clone 项目

git clone https://github.com/xxx/learngit.git

clone报错:fatal: unable to access 'https://github.com/xxx/learngit.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

git config --global --unset http.proxy
git config --global --unset https.proxy

查看用户名和邮箱地址

git config user.name
git config user.email

修改用户名和邮箱地址

git config user.name yourName
git config user.email yourEmail

删除文件

git rm -r yourFileName //  这种方式相当于右键本地磁盘删除的效果,如果 push到远端自然就删除了
git rm -r --cached yourFileName // 有人说这种不会删除本地,一旦 push 到远端,会将远端的该文件删除,但是我尝试的是无论是本地还是远端都不会被删掉,还是别整这些花里胡哨的,直接右键删除不香吗

关于.DS_Store

// 如果远端已经有了.DS_Store 文件,需要先删除本地文件
find . -name '*.DS_Store' -type f -delete
git add .
git commit -m 'delete .DS_Store'
git push
// 此时远端库已经没有了.DS_Store 文件

// 添加该文件的忽略,进入 vim
vim .gitignore
// i 进入编辑模式,输入以下内容
.DS_Store 
*/.DS_Store 
// ESC 进入底部命令模式输入以下内容:
:wq // 进入底部命令模式,保存并退出
// 正常push 到远端即可

显示mac隐藏文件:command + shift + .

你可能感兴趣的:(Git 常用操作及常见问题整理)