Common instructions of git(git常见指令)

git add .

add your codes to computer staging area

提交你的代码到暂存区

git status 

view the status of added files in computer staging area

查看暂存区已提交文件状态

 git commit -m "message"

add your codes to your local branch

添加你的代码到你的本地分支上

 git pull origin ***

pull the latest codes of your branch to the locality,you can get the latest codes the branch.if you find the message is 'Already up to date' after you have pulled,it means that your branch's content is the latest.

拉取你的分支最新的代码到本地,你可以得到该分支最新的代码,如果在你拉取完代码后发现消息是‘Already up to date’,意味着你的代码内容是最新的。

git push origin *** 

push your latest codes to your origin branch。

把你的最新代码推到远程分支上。

 git checkout -b 'test'

create a new branch named 'test' and switch to the new branch

创建一个新的分支,而且切换到该分支下

 git reset --soft HEAD^

reset your codes to 'added' status,for example,if you have done 'git commit -m ...',but you want to back,you can use the instruction

回退你的代码到added状态,举一个例子,你已经做了commit指令,你想返回,你用这个指令

git reset HEAD^ 

reset your codes to the status of before adding,for example,if you have done 'git commit -m ...',but you want to back to the initial state,you can use the instruction.then you want to add your codes again,you need to use 'git add .'

回退你的代码到提交之前状态,举一个例子,如果你已经commit了,但是你想回到初始的状态,你可以用这个指令,然后你想再次提交你的代码,你需要用git add .

 git reset --mixed HEAD^

the effect is the same as 'git reset HEAD^ '

效果和git reset HEAD^一样

git reset --hard HEAD^ 

use this carefully,beacause this can let your codes lose.Unless you don't need it

慎重用这个,因为这个可以让你的代码丢失,除非你不需要

git stash/ git stash save 'test1'

when you were writing your codes,someone told you need develop other content at another branch,you can use it to store you codes

当你正在写代码的时候,有人告诉你需要在其他分支开发内容,你可以用这个指令储存代码。

git stash pop / git stash pop stash${}

you can make you stored codes to branch you need,use it with 'git stash'

你可以把你储存的代码到你需要的分支上,和git stash配合使用

git stash apply/ git stash apply stash${}

it's effect is same as 'git stash pop',when do you use it?if you don't want the content of stash list,you use 'git stash pop' ,if no,you use 'git stash apply'

这个效果和git stash pop一样,那什么时候我们用这个呢,如果你不想要stash列表中的内容,你用git stash pop,如果你想要,你用‘git stash apply’

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值