您的位置:首页 > 其它

git常用命令详解

2015-10-12 14:03 274 查看
克隆代码库

git clone

初始化代码库

git init

查看分支状态

git branch

比较代码不同

git diff

向代码库添加代码

git add

向代码库提交代码

git commit

把本地代码推到远程主机上

git push

git push 默认将当前分支推送到remote的同名分支上,如果只输入 git push origin 则会提示warning:

warning: push.default is unset; its implicit value is changing in

Git 2.0 from ‘matching’ to ‘simple’. To squelch this message

and maintain the current behavior after the default changes, use:

git config –global push.default matching

To squelch this message and adopt the new behavior now, use:

git config –global push.default simple

When push.default is set to ‘matching’, git will push local branches

to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative ‘simple’

behavior, which only pushes the current branch to the corresponding

remote branch that ‘git pull’ uses to update the current branch.

See ‘git help config’ and search for ‘push.default’ for further information.

(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode

‘current’ instead of ‘simple’ if you sometimes use older versions of Git)

所以在使用git push 的时候,要么使用origin 并指明分支,要么不使用origin

更新远程主机代码到本地

git pull

合并代码

git merge

git rebase

git cherry-pick

查看日志

git log
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: