Git
Github教程:https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git
推送push 拉取pull
用sourcetree管理
查看配置信息
1git config --list
配置用户信息
1git config --global user.name "runoob"
2git config --global user.email test@runoob.com
查询配置信息
1git config user.name
创建Git
初始化
1git init
提交到暂存区
1git add .
可以通过 git status
查看现在的状态
绑定个人信息(存在可以跳过)
1git config --global user.email "xxx@qq.com"
2git config --global user.name "xxx"
提交到本地仓库
1git commit -m "第一次提交"
在Github上创建空的远程仓库
添加目标仓库地址
1git remote add origin https://github.com/xxx/xxx.git
由于Github在2021年8月13日取消了对密码身份验证的支持,从而转用个人访问令牌创建。
Github:Settings->Developer settings->Personal access token->Tokens(classic)
推送
1git push -u origin "master"
克隆
克隆
1git clone <repo> <directory>
切换分支
查看分支名称
1git branch -a
切换分支
1git switch 分支名称
2
3git switch master
常用命令
提交暂存文件
1git add .
撤销暂存
1git reset HEAD
撤销滚暂存前的修改
1git checkout .
撤销全部修改(包括暂存)
1git checkout HEAD .
提交暂存文件
1git commit -m '备注'
当前状态
1git status
比较暂存区和工作区差异
1git diff
回退
1git reset HEAD^ # 回退所有内容到上一个版本
2git reset HEAD^ hello.php # 回退 hello.php 文件的版本到上一个版本
3git reset 052e # 回退到指定版本
提交历史
1git log
创建分支
1git branch (branchname)
切换分支
1git checkout (branchname)
合并release分支
1git merge release
标签
1git tag -a v1.0
:wq保存退出 :qa不保存退出
推
1git push
拉
1git pull
1git remote -v
2
3git remote rm origin
4
5git remote add origin gitlab@gitlab.
6
7git pull origin master
8
9git branch --set-upstream-to=origin/master master
10
11git config --global credential.helper store
12
13git pull
好用的readme工具
常见问题
添加了.gitignore 但是不生效
1git rm -r --cached .
2git add .
浏览量:加载中... 评论数:加载中...