git

117 阅读1分钟

提交流程

git init
git add . 
git add README.md
git commit -m "初始化"
git branch -M main
git remote add origin https://github.com/你的GitHub用户名/你的仓库名.git
git push -u origin main
#第一次用

问题1:connect to github.com port 443 after 21043 ms: Timed out

git config --global --unset http.proxy 
git config --global --unset https.proxy
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
git config --global http.sslVerify "false"

显示 Git 仓库的所有历史操作

git reflog

恢复被删除的 commit

git reset --hard b2f5e1a

查看 git add 之前的状态

git status

git已经add,怎么撤回

git rm -r --cached -f .

第一次push

git push -u origin master
这条命令会:
-   **把本地的 `master` 分支推送到 `origin` 远程仓库**
-   **同时设置 `master` 分支的上游(upstream)分支**
-   **以后你只需要执行 `git push` 就可以推送了**,不需要每次都指定 `origin master`