Skip to content

Instantly share code, notes, and snippets.

@node
Created December 24, 2013 01:55
Show Gist options
  • Save node/8107743 to your computer and use it in GitHub Desktop.
Save node/8107743 to your computer and use it in GitHub Desktop.
SCM & Tools
参考 http://blog.jobbole.com/53573/
目录:
创建一个远程的空代码库(在BitBucket上或Github上)
在本地代码库添加一个项目
在分支上开发新功能
a) 保留新功能 或者 b) 丢弃它们
也许,回到某个早先的时间点
将本地代码库推送到远程代码库
在另一台机器上取得远程代码库
配置
git config --global user.name "your_username"
git config --global user.email your_email@domain.com
git config --global push.default simple
创建本地代码库
cd ~/workspace/my_site/
git init
加载文件
git add .
git add my_file, my_other_file
提交文件
git commit -m "initial commit"
git status
创建分支
git checkout -b new_feature
git branch new_feature
git checkout new_feature
git branch
合并分支
git add .git commit -m "adds my new feature"
git checkout master
git merge new_feature
丢弃分支
git add .git commit -m "feature to be discarded"
git checkout master
删除分支
git branch -d new_feature
git branch -D new_feature
回滚
git log
git checkout 085bb3bcb
git checkout -b my_previous_version 085bb3bcb
首次提交代码,提交代码
git remote add origin https://your_username@bitbucket.org/your_username/name_of_remote_repository.git
git push origin master
获取代码,更新代码
git clone https://your_username@bitbucket/your_username/name_of_remote_repository.git
git pull origin master
别名
git config --global alias.c 'commit -m'
git config --global alias.co 'checkout'
git config --global alias.cob 'checkout -b'
git config --global alias.br 'branch'
git config --global alias.m 'merge'
git config --global alias.a 'add .'
git config --global alias.s 'status'
git config --global alias.dbr 'branch -d'
More http://git-scm.com/documentation
@node
Copy link
Author

node commented Dec 27, 2013

开发者日常使用的 Git 命令 http://blog.jobbole.com/54184/
原文:https://www.kernel.org/pub/software/scm/git/docs/everyday.html

个人开发者(单独开发)

单独的个人开发者不会与他人交换修补程序,只用到下列命令,独自在单独的代码库上工作:

git-init(1)用来创建新代码库。
git-show-branch(1)用来查看你在哪里。
git-log(1)查看发生过什么。
git-checkout(1)和git-branch(1)用来切换分支。
git-add(1)用来管理索引文件。
git-diff(1)和git-status(1)查看你正在做什么。
git-commit(1)将内容推进现分支
git-reset(1)和git-checkout(1)(带路径名 参数)放弃修改。
git-merge(1)用来合并本地分支
git-rebase(1)用来维护主题分支
git-tag(1)用来给已知点打标签

个人开发者(参与开发)

作为在一个团体项目里参与角色的开发人员,需要学习如何与他人沟通,除了那些单独开发者需要掌握的命令以外,还要使用这些命令。

git-clone(1)从上游代码库填充你的本地代码库。
git-pull(1)和git-fetch(1)从“origin”得到最新的上游代码库。
git-push(1)用来共享代码库,如果你采用cvs风格的代码库工作流的话。
git-format-patch(1)用来准备e-mail提交,如果你使用Linux内核风格的公共论坛工作流的话。

集成人员

在一个团队项目中担任集成者的是一名相当重要的人员,他接受别人的修改,评审并且集成并且发布结果,供他人使用;除了那些参与者需要的命令之外,还会使用这些命令。

git-am(1)用来采用你的贡献者发电邮寄来的补丁文件。
git-pull(1)用来从你的可信任的助手处合并内容。
git-format-patch(1)用来准备并向你的贡献者发送建议选项。
git-revert(1)用来撤销不好的提交。
git-push(1)用来发布最新的内容。

代码库管理

代码库管理员使用下列工具来设置及维护开发者对代码库的访问。

git-daemon(1)允许匿名者从代码库下载
git-shell(1)可以被用作为限制登录shell,用于共享中央代码库的用户
update hook howto有一个很好的管理共享中央代码库的实例。

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