git checkout

git checkout的主要功能就是迁出一个分支的特定版本。默认是迁出分支的HEAD版本
示例:

git checkout master //取出master版本的head。
git checkout tag_name //在当前分支上 取出 tag_name 的版本
git checkout master file_name //放弃当前对文件file_name的修改
git checkout commit_id file_name //取文件file_name的 在commit_id是的版本。commit_id为 git commit 时的sha值。

$ git checkout -- hello.rb
这条命令把hello.rb从HEAD中签出.
$ git checkout .



这条命令把 当前目录所有修改的文件 从HEAD中签出并且把它恢复成未修改时的样子.
注意:在使用git checkout 时,如果其对应的文件被修改过,那么该修改会被覆盖掉。


git checkout -b|-B <new_branch> [<start point>]
git checkout [--detach] [<commit>]
This form switches branches by updating the index, working tree, and HEAD to reflect the specified branch or commit.

If -b is given, a new branch is created as if git-branch(1) were called and then checked out; in this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.

git和版本库有冲突时解决办法:
[b]先执行以下pull动作,然后在执行push动作[/b]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值