您的位置:首页 > 其它

版本控制管理工具--git的学习记录

2015-07-13 16:35 627 查看
起步:

1.git的三种状态,git status命令:modified,staged,commited

2.git安装:1.使用安装包 2.从源码安装(优)

3.配置存放目录: /etc/gitconfig git config命令使用--system选项

~/.gitconfig 用户目录 --global选项

.git/config 当前项目工作目录

4.配置文件编辑器: git config --global core.editor vim

5.配置差异分析 git config --global merge.tool vimdiff

6.查看配置:git config --list

git config user.name

7.帮助:方式一: git help config

方式二:git <verb> --help

方式三:man git-<verb>

基础:

8.取得项目git仓库 1.从已有项目 在项目目录下git init

2.clone git clone git://........... mygrit (mygrit为自定义目录名默认为grit)

9.git add 文件名 纳入版本控制,进入暂存状态

git status 可以查看暂存状态 和未纳入版本控制,修改但未提交的文件

git commit 提交,必须要经过git add的文件才会被提交

10.配置gitignore文件 cat .gitignore 是不是就先用vim创建一个.gitignore文件呢?

11.查看具体修改了哪些地方 git diff 已修改但未暂存和快照的差异

git diff --cached 已暂存和快照间差异

12.提交时加参数:git commit -v (将修改差异的每一行显示到注释)

git commit -m "注释说明"

13.跳过暂存提交:git commit -a 对所有已跟踪的文件暂存并提交

14.删除文件:git rm filename (删除本地并从暂存中删除)提交后不会纳入版本控制了,也可以先手动删除本地文件

git rm -f finlename (已经暂存时加-f)

git rm --cached filename (从暂存中删除)但本地保留

15.移动文件: git mv oldname newname

相当于:mv oldname newnamne

git rm oldname

igt add newname

16.提交历史:git log

gil log -p -2 (还有--stat --pretty常用)

17.查看当前配置有哪些远程仓库, git remote 命令

18.提交到远程仓库:git push origin master origin仓库名,master是分支名

19.标签查看:git tag

分支:

19. git branch branchname

20.git checkout branchname

在服务器部署 Git:

21. 克隆纯仓:$ git clone --bare my_project my_project.git

22. 将纯目录转移到服务器(假设一个域名为 git.example.com 的服务器已经架设好,并可以通过 SSH 访问,而你想把所有的 Git仓库储存在 /opt/git 目录下):

$ scp -r my_project.git user@git.example.com:/opt/git

---实战-在服务器部署 Git(服务器为Ubuntu系统)---

ssh登录服务器后:

1.安装:apt-get install git-core

2.创建/home/projects/git 用于存放git仓库

客户端本地:

1. 在本地做一个仓库(也可以找一个已有仓库):

cd /home

mkdir gexiuserver

cd gexiuserver

git init

2.克隆纯仓(gexiuserver是第一步中创建的仓库或是已前的仓库):

cd /home

git clone --bare gexiuserver gexiuserver.git

就可以在/home目录下找到一个gexiuserver.git文件目录了

3.将纯目录转移到服务器:

scp -r gexiuserver.git user@example.com:/home/projects/git

4.使用:

git clone ssh://user@example.com//home/projects/git/gexiuserver.git

cd gexiuserver

get push origin master (第一次push要加仓库与分支名origin master以后就不需要了)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: