由于项目需要学习一些关系Git 的相关知识。尽快入门选择了廖雪峰老师的相关教程,实际操作过程中,结果不尽相同,所以结合实际操作和网络上其他的人解决方法,写这个系列的学习笔记。
开发平台 : IMac + iterm2
Git 安装
首先由于是直接使用命令行安装,在 Mac中需要安装homebrew ,直接复制下面的链接就可以直接安装 homebrew。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装完成之后就可以使用 brew 安装和管理软件了,跟apt-get install
类似。
brew install git
然后就可以愉快的使用 git 了。
Git 使用
mkdir learngit
cd learngit
git init
然后就在当前learngit的目录下新建readme.txt
vim readme.txt
并在文件中写入
git is a version control system
然后执行,这里 add 这个命令可以执行多次。然后一并提交。
git add readme.txt
执行完上面的命令后,没有提示就通过了。然后提交
git commit -m "wrote a readme file"
廖雪峰老师的网页上这里直接通过,但是我运行后提示
* Please tell me who you are.
Run
git config –global user.email “[email protected]”
git config –global user.name “Your Name”to set your account’s default identity.
Omit –global to set the identity only in this repository.
这个是需要在~/learngit/.git/config
文件中添加
[user]
email = [email protected]
name = yourname
据说随便写就可以了。
然后重新 commit 就可以通过了。