git基本用法
- git clone 网页链接(从仓库获取)
- git branch -m master main (把分支master改为main)
- git init
- git add .
- git commit -m "first commit"
- git status(获取状态)
- git remote add origin …url(本地仓库连接到远程仓库)
- git push -u origin main(首次推送加上将main推送到远程仓库,记住这个关系,后续只需:git push)
- git rm --cached 取消追踪文件
- git rm --cached -r 取消追踪文件
- git restore --staged 取消暂存
- git reset --soft HEAD~1 取消commit,保留更改
- git reset --hard HEAD~1 取消commit,不保留更改
git使用25.4.3(全局和局部配置)
- git config --global user.name ""
- git config --global user.email ""
- git config --local user.name ""
- git config --local user.email ""
分支
- git branch(查看分支)
- git branch -d …(删除分支)
- git branch …(创建分支)
- git checkout …(切换到…分支)
- git branch -b …(创建并切换分支)
- git merge …(把…分支合并到当前分支)
- git rebase …(危险操作,合并分支,注意!会改写历史)
- git push(推送现有分支)
新建的分支推送
- git checkout …
- git push -u origin …
vscode git插件
连接他人仓库
- git init
- git remote add origin [email protected]…
- git fetch -a(获取所有分支)
- git pull orgin …(拉取分支)
历史记录
- git log
- git reflog
- git reset --hard …(版本回退)
- 本文作者:霂枯木
- 本文链接:https://timcoumu.cn/posts/Git基础
- 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 许可协议。