赞
踩
与CVS、SVN等集中式版本控制工具不同,Git是分布式版本控制工具。开发人员通过Checkout从中心版本库Copy一个完整的版本库到本地,就算不联网也可以进行commit、update等操作,而且每次操作都是在本地进行,因而速度非常快。同时可以通过Push操作把代码提交到远程仓库,通过pull操作从远程仓库拉取最新代码。
基于Git的代码托管平台有GitHub、GitLab、Coding.net、开源中国、CSDN、Bitbucket等。其中用户量最多、使用最广泛的当属GitHub,它常常搭配GitHub for Windows(一款针对GitHub平台的Git客户端软件,当然也可以用它来访问其他Git服务器)一起使用。另外,GitHub还是一个大型的开源社区网站,号称程序员最爱逛的网站。
常用的Git客户端:GitHub for windows、TortoiseGit、msysGit(也叫Git for Windows,Git在Windows的客户端)等,前两者都基于后者,GitHub for Windows内置了一个msysGit,所以不需要单独安装。
也可以搭建自己的Git服务器(类似GitHub的代码托管平台):由于GitHub上托管私有项目需要收费,所以我们可以借助一些开源的工具来搭建一个类似的平台,我们选择在Windows中比较常用的Gitblit;
一. GitHub:
三. Git命令行:
Eclipse和Idea都提供了Git的图形界面客户端。我比较习惯用命令行,所以在转用Idea之前我都用git bash(http://git-scm.com/downloads 由此下载并安装,按需要选择配置SSH )。 分享一些经常用的git命令行吧。
git status git status >> <log_path> git clone <repo_name> git checkout <branch_name> git checkout -b <branch_nmae> git checkout -b <branch_name> origin/<branch_name> git checkout . git checkout -- <file_path> git checkout <commit_id> <file_path> git tag <tag_name> git push origin <tag_name> git tag -d <tag_name> git push --delete origin <tag_name> git branch git branch -m <old_branch_name> <new_branch_name> git push origin :<old_branch_name> git push --set-upstream origin <new_branch_name> git push -u <new_branch_name> git branch | xargs git branch -d -->xargs代表因此错误 git branch | grep 'dev*' | xargs git branch -d --> grep是查找 git branch -d <branch_name> git branch -r -d origin/<branch_name> git merge dev git merge dev >> <log_path> git merge --abort git reset --hard <commit_id> -->让HEAD指向该commit,该commit之后的所有记录将被清除。 git revert <commit_id> -->是用一次新的commit来回到之前的commit状态,会产生一次新的commit,中间的记录会被保留。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。