工作区:电脑上看到的目录
版本库(Repository):工作区上的隐藏目录.git
暂存区(stage):版本库上的东西
master:git为我们自动创建的第一个分支,在版本库上
HEAD:指向master的指针,在版本库上
ssh-keygen -t rsa -C "531338153@qq.com":创建ssh_key
git remote add origin https://github.com/cherrying-rysx/cherrying.git:创建github连接
git push (-u) origin master:把主分支master推送到远程(输入github用户名,密码Qq14****3)
git push -f origin master
当push失败,pull后push还是失败,强制push。(注意:大家千万不要随便用-f的操作,因为f意味着强制push,会覆盖掉远程的所有代码!)
git clone https://github.com/cherrying-rysx/cherrying.git:克隆一个本地库
git remote:查看远程库信息
git remote -v:查看远程库详细信息
git checkout -b BranchName origin/BranchName : 创建远程origin的分支到本地
git pull:把最新的提交从远程抓下来(当推送失败的时候)
git branch --set-upstream BranchName origin/BranchName:指定本地分支与远程分支的链接
git config --global user.name "cherrying":创建仓库用户名
git config --global user.email "531338153@qq.com":创建仓库邮箱
git init:在当前目录下创建一个.git版本库
git add FileName:把文件添加到暂存区
git commit -m "提交注释":一次提交所有暂存区的内容
git status:查看文件状态
git diff FileName:查看文件改变内容
git log:
git log --pretty=oneline:查看修改历史信息
git reset --hard HEAD^:回退到上个版本
git reset --hard HEAD^^:回退到上上个版本
git reflog:查看版本号
git reset --hard 版本号:恢复到版本号处的信息
git checkout -- FileName:丢弃工作区的修改,恢复为暂存区内容
git branch:查看分支
git branch BranchName:创建分支
git checkout BranchName:切换分支
git checkout -b BranchName:创建并切换分支
git merge BranchName:合并指定分支到当前分支
git merge --no-ff -m BranchName:合并指定分支到当前分支(禁用fast forward模式)
git branch -d BranchName:删除分支
git stash:在使用bug分支前把当前工作现场隐藏起来
git stash list:查看工作现场
git stash apply:恢复工作现场
git stash drop:删除工作现场
git stash pop:恢复并删除工作现场
git rm FileName:删除文件