Git


title: Git
date: 2016-09-29 13:26:57
tags:

我是前言

目的:搭建好了博客,不可能每次发表博客的时候都带着我这台台式机乱跑吧,如果换到其他电脑怎么办,博客的部署文件都在这台电脑上,所以就想着同步到github上,又不想创建一个新的repo还单独存储源文件,就像在发布的网站的repo中创建一个分支来存储当前的blog源文件,于是风雨之路慢慢而来,因为这几天要过10.1,所以赶紧整理一下这两天git的学习内容

准备工作

  • 创建repo然后创建本地库,git pull 远程库 如下图

创建分支


git checkout - b Hexo  //Hexo 是分知名 创建并切换到当前分支

//等价于下面
git branch Hexo

git checkout Hexo //

示意图


远程repo上查看

本地命令行查看

查看本地分支:

 git branch

如图

查看远程分支:

 git branch -r

如图


删除分支

创建删除都是常用的,我就一并归纳了,虽然还没用到

git branch -d Hexo

切换分支

git checkout master (前面提到的)切换到主分支

将本地分支push到远程分支

git push origin [name]

补充方法


git push origin test :master //将本地test分支作为远程的master分支



git push origin  test : test //将本地的test分支作为远程的test 分支

遇到的问题

1.hexo的两个主题 git commit 时无法提交
报错信息:

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

	modified:   themes/next (modified content)
no changes added to commit (use "git add" and/or "git commit -a")```

解决方案:


Bean HE http://kubiops.com/2015/09/06/ignore-dirty-status/


问题分析:

* 主要是看了解决方法,并不是真正的将主题提交,而是ignore dirty(肮脏的) info in git ,所以我断定应该是github上开源的项目在提交的时候会自动连接到github上的远程库,去查看了一下远程库的状态,如下图

参考

追寻最真
原文地址:https://www.cnblogs.com/zhao-jie-li/p/5921093.html