分布式的版本控制系统 Git 常用操作

fmms 12年前
     <div id="article_content" class="article_content">     <p>Git是一款分布式的版本控制软件,相比SVN,功能更强大,自然而然操作更复杂一些。git在本地也是以git版本库的形式管理,而SVN在本地管理的仅是一个版本库的副本。很明显的一个不同点:git你可以在本地做一些修改,然后commit到本地的版本库,最后push到服务器,而SVN只要一commit,更改就已经提交到服务器。</p>     <p>以下是git的一些常用操作:</p>     <p>查看命令帮助信息<br /> <strong># git <command> -h<br /> </strong>如:git add -h</p>     <p>设置name、email<br /> <strong># git config --global user.name LiXianlin<br /> # git config --global user.email xianlinli@gmail.com</strong></p>     <p>查看设置<br /> <strong># git config --list</strong></p>     <p>创建版本库<br /> <strong># git init</strong></p>     <p>添加文件<br /> <strong># git add 文件名或路径</strong></p>     <p>删除文件<br /> <strong># git rm 文件名</strong></p>     <p>提交<br /> <strong># git commit -m '提交备注信息'</strong></p>     <p>查看分支<br /> <strong># git branch</strong></p>     <p>创建分支<br /> <strong># git branch local</strong></p>     <p>删除分支<br /> <strong># git branch -d local</strong></p>     <p>查看tag<br /> <strong># git tag</strong></p>     <p>创建tag<br /> <strong># git tag v1.0.1</strong></p>     <p>删除tag<br /> <strong># git tag -d v1.0.1</strong></p>     <p>克隆版本库<br /> <strong># git clone 版本库地址<br /> # git clone 版本库地址 本地保存路径</strong></p>     <p>设置远程版本库<br /> <strong># git remote add [-t <branch>] <name> <url><br /> </strong>如:git remote add -t master origin git@github.com:lixianlin/redis-cli.git</p>     <p>拉取远程版本库<br /> <strong># git pull <repo><br /> </strong>如:git pull origin</p>     <p>提交更改到远程服务器<br /> <strong># git push</strong></p>     <p>提交tag<br /> <strong># git push --tags</strong></p>     <p>删除远程tag<br /> <strong># git push origin :refs/tags/tag名称<br /> </strong>如:git push origin :refs/tags/v1.0.1</p>     <p><br /> 附:<br /> git项目主页:<a href="/misc/goto?guid=4958183577944756424">http://git-scm.com/</a> 已被墙,可到<a href="/misc/goto?guid=4959500213989806931">http://download.chinaunix.net/download/0004000/3744.shtml</a>下载<br /> <br /> 转自:<a href="/misc/goto?guid=4959500214084699724">http://blog.csdn.net/lixianlin/article/details/7171927</a><br /> </p>    </div>