by Chunze.Huang
人生苦短,何不用GIT?
1. 底层的文件系统
2. 去中心化
3. 社区趋势
跟SVN不同的是Git 底层文件系统存储的为文件快照,即整个文件内容保存指向快照的索引。
考虑到性能因素,如果文件内容没有发生任何变化,该文件系统则不会重复保存文件,只是简单地保存文件的链接。
1. 安装
2. 配置
3. 基础命令
yum install git # way 1
apt-get install git-core # for ubuntu
# way 2
yum install gettext curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel -y
yum -y install zlib-devel curl-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib autoconf tk perl-ExtUtils-MakeMaker
wget https://github.com/git/git/archive/v2.11.0.tar.gz
tar xzvf v2.11.0.tar.gz
cd git-2.11.0
autoconf
./configure
make
sudo make install
cat .git/config
####################################
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = http://code.xxoo.com/test/phplib.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
email = yourmail@mail.com
name = yourname
cat ~/.gitconfig
###############################
[user]
name = your name
email = yourmail@mail.com
[push]
[http]
sslVerify = false
[push]
default = matching
[credential]
helper = osxkeychain
[core]
autocrlf = false
git config [--global] [seting=values]...
如果你习惯linux or mac下开发,可以打开terminal执行下面命令
git config --global user.name "your username"
git config --global user.email "your email address"
git config --global core.autocrlf true
git config --global core.safecrlf true
1. 通用工具
2. 其他工具
相同点:都是用 Command-line 来与系统进行交互
不同点:命令基本都不一样
Windows: cmd、PowerShell、Cmder
Linux: Terminal、iTerm
cd /www/37/git
mkdir git-learn
cd git-learn
git init
touch 1.php
add 1.php
commit -m 'first commit'
remote add origin https://github.com/boxcore/git-learn.git
push origin master
1. SVN-GIT迁移
2. 解决代码冲突
3. 合并代码
1. GIT-SCM
2. 码云帮助
3. Coding.net
1. GIT-SCM:
https://git-scm.com/downloads
2. cmder (window用户cmd替代工具):
https://github.com/cmderdev/cmder/releases
3. homebrew(Mac用户terminal工具):
https://brew.sh/
4. TortoiseGit(Win用户Git-GUI工具):
https://tortoisegit.org/download/