git status -s
git branch
git pull
git add .
git commit -m “msg”
git checkout branchname
git merge brachname
git log --pretty=oneline
版本回退:git reset --hard HEAD^ 内容也是要回退的
git reset --hard HEAD^^
git reset --hard HEAD~100
版本号:git reflog
git reset --hard 版本号
撤销修改:
git reset --hard HEAD^
git checkout -- filename: 分两种情况,第一种是文件修改后,还没有放到暂存区,使用撤销修改就回到和版本库一模一样的状态。另外一种是文件已经放入暂存区了,接着又作了修改,撤销修改就回到添加暂存区后的状态。(都是没有提交的前提下)
删除文件:
rm filename,如果还没有commit,那么可以通过git checkout -- filename恢复
git branch name:创建分支
git checkout branchName:切换分支
git checkout -b branchName:创建+切换分支
git merge name:合并某分支到当前分支
git branch -d branchName:删除分支
git branch --set-upstream-to-origin/test 当前的分支和远程建立关联
git clone 地址 -b 分支名 重命名
git branch -vv
git checkout -b branchName origin/branchName:创建新的分支和远程分支一样
git push origin test:如果远程没有会建立分支
git pull=git fetch+git merge
git push origin :test删远程分支
git branch -vv:
能查看本地哪些分支和远程分支建立了关联。
git branch -a:
查看所有的分支,本地的和远程的,远程的是用红色标记的
git branch:
查看本地的分支
clone的时候就建立分支关联:
git clone 地址 -b 分支名 [重命名]--这个是git工程的重命名
建立同远程分支关联的本地分支:
git branch -b newLocalBranchName origin/branchName:
删远程分支:
git push origin :test
本地新建分支并推到远程:
git push origin localBranchName
本地新建分支并推到远程并与远程关联:
git push origin -u localBranchName
push之前必须pull