- git init 初始化本地库
- git status 查看工作区、暂存区状态
- git add [file name] 将工作区的文件提交到暂存区
- git commit -m “描述” [file name] 将暂存区的文件提交到仓库
- git config --global user.email “you@example.com” 全局配置签名 email
- git config --global user.name “Your Name” 全局配置签名 name
- git log 查看历史记录
- git reflog 查看历史记录 HEAD@{移动到所在版本需要的步数}
版本前进、后退
git reset --hard [HASH索引值] 基于索引值进行版本指定
git reset --hard HEAD^ 后退一步
git reset --hard HEAD~n n 表示后退 n 步
- git diff 不带文件名比较多个文件
- git diff [file name] 将工作区的文件和暂存区进行比较
- git diff HEAD^ [file name] 工作区的文件和历史版本中的文件进行比较
- git branch -v 查看分支情况
- git branch [branch name] 创建分支
- git checkout [branch name] 切换分支
- git merge [otherbranch] 合并分支,otherbranch 指得是要将其他的分支内容合并到所在分支
合并冲突
当两个分支都对同一个文件进行了修改,发生了修改结果不一致,产生了冲突
解决方案:
git merge [otherbranch] 然后进入【MERGERING】状态,
手动修改冲突文件,删除附加文件
git add [file name] 将工作区的文件提交到暂存区
git commit -m “描述” 退出【MERGERING】状态,合并完成!
- git remote -v 查看远程推送、拉取别名对应的 URL 地址
- git remote add [alias] [remote url] 添加远程推送、拉取别名对应的 URL 地址
- git remote remove [alias] [remote url] 删除远程推送、拉取别名对应的 URL 地址
- git push [alias] [branch name] 将本地仓库推送到远程地址仓库
- git clone [remote url] 从远程仓库克隆到本地仓库
- git fetch [alias] [branch name] 从远程仓库抓取到本地仓库
- git merge [alias/branch name] 将上一个命令抓取的结果和当前分支合并
- git diff [alias/branch name] [file name] 将远程抓取的内容和本地仓库内容进行对比
- git pull [alias] [branch name] pull = fetch + merge
SSH 登录
cd ~ 进入当前用户家目录
rm -rvf .ssh 删除 .ssh 目录
ssh-keygen -t rsa -C [account] 生成 .ssh 密钥目录
cd .ssh 进入 .ssh 目录查看文件列表
cat id_rsa.pub 查看 id_ras.pub 文件内容并复制
用户头像 -> Setting -> SSH and GPG keys 设置 GitHub SSH Key,将上述的信息复制到新创建的 SSH Key 中
git remote add [alias] [ssh url] 回到 Git Bash 创建远程地址别名
2095

被折叠的 条评论
为什么被折叠?



