- 使用Git管理代码
Git 官网地址:http://git-scm.com
- Git安装
windows直接从官网download下载,有客户端安装(CMD下使用)。
linux分yum 与 apt-get安装方法都比较简单。
yum install git apt-get install git
- Git源码文件存放位置
管理中源码会存放在四个位置分别是,本地目录、提交列表、本地仓库、远程仓库。
- 配置文件 (主要配置用户标识,使用者,邮箱等信息)
-
- 全局配置
linux下root目录下隐藏文件 .gitconfig
-
- 本地目录配置
当前git目录中隐藏文件夹 .git/config
- 创建Git目录 git init
假如在linux中home目录下创建 code目录,使用该目录作为管理位置。
root@MyUbuntuCloud:/# mkdir /home/code root@MyUbuntuCloud:/# cd /home/code root@MyUbuntuCloud:/home/code# git --version git version 1.7.9.5 root@MyUbuntuCloud:/home/code# git init Initialized empty Git repository in /home/code/.git/ root@MyUbuntuCloud:/home/code# ll total 12 drwxr-xr-x 3 root root 4096 Apr 20 00:00 ./ drwxr-xr-x 6 root root 4096 Apr 19 23:58 ../ drwxr-xr-x 7 root root 4096 Apr 20 00:00 .git/ #出现了.git目录
root@MyUbuntuCloud:/home/code# ll .git/
total 40
drwxr-xr-x 7 root root 4096 Apr 20 00:00 ./
drwxr-xr-x 3 root root 4096 Apr 20 00:00 ../
drwxr-xr-x 2 root root 4096 Apr 20 00:00 branches/
-rw-r--r-- 1 root root 92 Apr 20 00:00 config #可以看到配置文件
-rw-r--r-- 1 root root 73 Apr 20 00:00 description
-rw-r--r-- 1 root root 23 Apr 20 00:00 HEAD
drwxr-xr-x 2 root root 4096 Apr 20 00:00 hooks/
drwxr-xr-x 2 root root 4096 Apr 20 00:00 info/
drwxr-xr-x 4 root root 4096 Apr 20 00:00 objects/
drwxr-xr-x 4 root root 4096 Apr 20 00:00 refs/
root@MyUbuntuCloud:/home/code# git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# new.py
nothing added to commit but untracked files present (use "git add" to track)
12点了 明天编辑