git branch test // 创建本地分支
git checkout test //切换分支
修改代码
git add . //实际上就是把文件修改添加到暂存区
git commit -a -m "对修改的描述"//把暂存区的所有内容提交到当前分支
git push origin test(远程) :test(本地) //创建远程分支
git push // 将更改推到远程test分支 git push --set-upstream origin maji 本地与远程建立联系 ;将远程指定分支 拉取到 本地当前分支上:git pull <远程仓库名> <远程分支名>(:<本地分支名>)//省略括号内容
//在另一主机上创建test分支并将远程test分支 拉取到本地 test 分支
git branch test
git pull origin test:test
git branch -b test origin : test //创建本地分支并与远程分支关联 ,可以测试代码
git log test...master //查看两个分支的差别
放弃修改:
未使用 git add 缓存代码时:git checkout 文件名
已经使用了 git add 缓存了代码:可以使用 git reset --hard HEAD^ 来回退到上一次commit的状态。此命令可以用来回退到任意版本:git reset --hard commitid