git(1)

(1)为特定的项目设置user.name和user.email

这些内容可以在项目的目录中查看到。

chapter2:git 基础

(1)记录每次更新到仓库

查看当前文件状态:git status

跟踪新文件:git add README,开始跟踪README文件。

暂存已经修改的文件:可以先用git status查看状态,再git add

状态简单查看:git status --short

ignore文件:编写 .gitignore文件。

查看暂存与没暂存的修改:如果git status 输出太简单,可以使用git diff ,它将显示具体的修改。

提交更新:git commit ,使用git commit -a 可以全合并add 与commit操作。

(2)查看提交的历史

查看所有的历史:git log

查看最近的两个提交历史:git log -p -2

(3)远程仓库的使用

远程仓库的查看:

里面的origin为git clone时的仓库服务器的默认名字。

添加远程仓库:git remote add shortname url

以后就可以用shortname来代替整个URL了,如git fetch url

从远程仓库中拉取所有你还没有的数据(分支):git fetch remote-name

推送到远程仓库:git push remote-name branch-name

如将master分支推送到origin服务器时(这两个名字在clone时默认的),可以使用

git push origin master

查看远程仓库:git remote show [remote-name],如运行git remote show origin,得到

 

这告诉我们正处于master分支。

远程仓库的命名与移除:

git remote rename old-name new-name

git remote rm old-name

chapter3:分支

(1)分支简介

分支创建:

我们可以看到,现在HEAD指向master,且master和study分支都指向校验和为e305c8b开头的对象。注意,master分支与其它分支相比并无区别。

分支切换:

git checkout new-branch

在新的分支上进行修改并提交后,我们可以查看分支图

(2)分支管理

查看当前所有的分支: git branch

查看当前每个分支的最后一次提交:git branch -v

查看已经或者还没有合并到当前分支的分支:git branch --merged/--no-merged

原文地址:https://www.cnblogs.com/chuiyuan/p/5362908.html