Skip to content

Instantly share code, notes, and snippets.

@chen206
Last active December 19, 2015 08:19
Show Gist options
  • Save chen206/5925124 to your computer and use it in GitHub Desktop.
Save chen206/5925124 to your computer and use it in GitHub Desktop.
git, 分布式

git config

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

共享设置

添加一个用户账号:git:123456

将atweiquan工程的父级目录共享,比如D:\work\atweiquan,将work共享 设置该共享目录,Everyone和git,具有读取权限

在git bash中,进入到atweiquan工程根目录,运行以下命令(除了自己的):

git remote add liu file:////192.168.1.88/repos_liu/atweiquan
git remote add wang file:////192.168.1.36/workspace_server/atweiquan
git remote add chen file:////192.168.1.64/repos_chenm/atweiquan
git remote add yang file:////192.168.1.7/work/atweiquan

也可以直接编辑./atweiquan/.git/config,修改wang和url部分

[remote "wang"]
    url = file:////192.168.1.36/workspace_server/atweiquan
    fetch = +refs/heads/*:refs/remotes/wang/*

开发流程

git clone

克隆整个项目

git clone [email protected]:atweiquan.git

一般操作

查看分支

git branch

切换到develop分支

git checkout develop

查看修改状态

git status

添加文件

git add <filename>

删除文件

git rm <filename>

提交代码,进入VI,i输入注释, :wq

git commit -a

获取他人最新的develop分支代码

git pull liu develop
git pull yang develop
git pull wang develop

分支开发

git checkout -b

在develop基础上创建功能分支feature-xxx,并切换到feature-xxx

git checkout -b feature-xxx develop

git commit

开发功能分支feature-xxx时,本地可以频繁add/rm/commit

git add xxxx
git commit -a -m "代码提交信息"

分支完成

开发完功能分支feature-xxx后,将feature-xxx合并到develop,删除feature-xxx

git checkout develop
git merge –-no-ff feature-xxx
git branch -d feature-xxx

获取他人最新的develop分支代码

git pull liu develop
git pull yang develop
git pull wang develop

其他常用操作

git fetch

获取他人的分支,feature-x是wang的分支,feature-y是本地分支名,可以=feature-x

git fetch wang feature-x:feature-y

git diff

比较

git diff

git log

日志

git log

一些参考

http://rogerdudler.github.com/git-guide/index.zh.html

http://www.ruanyifeng.com/blog/2012/07/git.html

http://gitbook.liuhui998.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment