git init 初始化
git clone http://... 克隆项目
git add 文件名 添加文件
git status 查看状态
git commit -m '备注' 添加备注
git push origin master 推送到云端
//git pull <远程主机名> <远程分支名>:<本地分支名>
*git push -f 强推(有时候出现冲突推送不上去时候使用)
git checkout -b dev 创建分支
--- Switched to a new branch 'dev'
git add
git status
git commit -m ""
git checkout master
--- Switched to a branch 'master'
git merge dev
git push origin master
//当出现这种错误时,表名readme文件没有更新
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to 'http://code.fieldschina.com/web/oa.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
//此时需要
git pull --rebase origin dev
如果继续提交,git status 出现rebase in progress; onto ed15f09a //之前或者刚刚用过 git rebase,但上一次的进程还没有完成。
则需 git rebase --continu
git push origin 远程分支:本地分支
推送本地分支local_branch到远程分支 remote_branch并建立关联关系
a.远程已有remote_branch分支并且已经关联本地分支local_branch且本地已经切换到local_branch
git push
b.远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
git push -u origin/remote_branch
c.远程没有有remote_branch分支并,本地已经切换到local_branch
git push origin local_branch:remote_branch
error: Pulling is not possible because you have unmerged files.
使用 git reset --hard FETCH_HEAD解决冲突
git MERGING状态
使用 git reset --hard head解决
git pull冲突 error: Your local changes to the following files would be overwritten by merge
如果希望用代码库中的文件完全覆盖本地工作版本
git reset --hard
git pull
Git取消add状态
git reset <HEAD>
查看本地对应的远程分支 git branch -vv
git stash save 'messag' 将修改的文件存入暂存区 不会提交
git stash pop 释放暂存区文件
git stash list 查看现有stash
撤销commit操作并返回到未commit状态
git log
git reset --hard commit_B_hash
git reset commit_A_hash
主分支对应的本地分支,切换到测试分支本地分支 git checkout -b locdev origin/develop
Git reset --hard commit_id(可用 git log –oneline 查看)
git push origin HEAD --force #远程提交回退