git 基本命令

工作区:电脑上看到的目录

版本库(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:删除文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值