oblind

常用git操作

更新.gitignore

git rm -r --cached .

git add .

git commit -m "update .gitignore" (提交)

git push origin master:master (推送)


撤销本地更改

git checkout .

注意有个点


本地回退

git reset xxxx --hard    //放弃所有更改

git reset xxxx --soft     //放弃提交,保留工作区


远程回退

git push -f origin master


分支操作

  • 创建分支库后与原库连接,以获取原库后续更新

    git remote add upstream 'https://github.com/username/package'

    或 vscode 中 git 页 -> 远程 -> 添加远程存储库

  • 查看关联库

    git remote -v

    会显示原库名(后面会用到)

  • 获取原库更新

    git fetch 原库名 master

    git log -p FETCH_HEAD    //即可看到原库最新更改

    git merge 原库名/master  //将原库合并到本地

    或 vscode 中 拉取,推送 -> 拉取自 -> 选择原库


查看设置

git config --global --list

使用代理

git config --global http.proxy https://127.0.0.1:port

git config --global https.proxy https://127.0.0.1:port

撤销代理

git config --global --unset http.proxy

git config --global --unset https.proxy


安装第三方依赖库

git submodule update --init


安装特定分支

git clone --b tagName https://github.com/xxx/yyy


恢复被composer重置的git仓库

进入仓库yyy

git clone --no-checkout https://github.com/xxx/yyy tmp

mv tmp/.git .

rmdir tmp

git reset --hard HEAD

评论