文章目录
  1. 1. 设置windows下git的home目录以及自动跳转

    
下一场比赛至关重要
Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能。本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Git远程操作。

参考了 阮一峰Git远程操作详解

Git远程操作详解

  1. 克隆远程仓库以及该仓库分支
    1
    git clone https://github.com/vivatakethat/vivatakethat.github.io.git

进入克隆好的仓库

查看远程仓库分支

1
git branch -r

建立本地对应分支

1
git checkout -b gh-pages origin/gh-pages

默认会进到新建的分支里,如果想进去其他分支,可以通过
git checkout 加分支名切换
如:
git checkout master

注意master就是local branch,origin/master是remote branch

QQ: 948557407


报错:

  1. untracked

在git中出现如下警告

1
2
3
4
5
6
7
8
λ git checkout -b gp-pages origin/gh-pages
error: The following untracked working tree files would be removed by checkout:

XXXXXXXX.X
XXXXXXXX.X

Please move or remove them before you can switch branches.
Aborting

解决方法

1
git clean  -d  -fx ""

其中
x —–删除忽略文件已经对git来说不识别的文件
d —–删除未被添加到git的路径中的文件
f —–强制运行

  1. fatal: Unable to create xxx .git/index.lock

    在分支下执行git add . 报的这种错

1
2
3
4
5
6
7
8
λ git add .
fatal: Unable to create 'D:/github/home/temp/vivatakethat.github.io/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

解决方法:
直接将.git目录下的index.lock文件删掉,然后重新执行上面的操作.

可是还会报错

1
2
3
4
5
6
7
8
9
10
11
takethat@acer ~/temp/vivatakethat.github.io/resume_takethat (gh-pages)
λ git add .
A s s e r t i o n f a i l e d !

P r o g r a m : D : \ P r o g r a m \ c m d e r \ v e n d o r \ g i t - f o r - w i n d o w s \ m i n g w 3 2 \ b i n \ g i t . e x e
F i l e : p a t h s p e c . c , L i n e 3 1 7

E x p r e s s i o n : i t e m - > n o w i l d c a r d _ l e n < = i t e m - > l e n & & i t e m - > p r e f i x < = i t e m - > l e n

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

无解?

设置windows下git的home目录以及自动跳转

打开Git安装位置\etc\profile文件添加以下

1
2
3
4
HOME="D:\github\home"
HOME="$(cd "D:\github\hexo-blog" ; pwd)"
cd
export PATH="$HOME/bin:$PATH"


  • first git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
…or create a new repository on the command line

echo "# vivatakethat.github.io" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:vivatakethat/vivatakethat.github.io.git
git push -u origin master
…or push an existing repository from the command line

git remote add origin git@github.com:vivatakethat/vivatakethat.github.io.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
文章目录
  1. 1. 设置windows下git的home目录以及自动跳转