`

git版本控制器简单使用

git 
阅读更多

Git Usage

 

1. Checkout source code

 $> git clone git@gitserver:job.git  (git@gitserver.xxxx.com:job.git)
 
 # config git with your name and email 
 $> git config --global user.name  "your real name" 
 $> git config --global user.email "your company email address" 
 
 # config reviewboard url  
 $> git config reviewboard.url http://xxxxxx.com 
 
 # install code review tool 
 $> sudo yum install RBTools
 $> sudo easy_install -U RBTools  

2. Make changes and submit a patch

 $> git pull --rebase # get latest code from server to apply to current branch  
 $> ... edit your files...
 $> git status # verify all changes 
 $> git diff # carefully check whether all changes are valid or not 
 $> git commit -am "the message of changes" 
 $> git format-patch -k -1 # pust last commit in local tree to a patch 

3. Create a branch to do development

 $> git checkout -fb develop origin/develop #  develop to track original develop
 $> git checkout -fb bug<num> origin/develop # create a feature or bug branch based on develop
  
 $> ... edit your files   
 # ready to checkin
 $> git add <files to checkin> 
 $> git commit -m "message" 
  
 # some other developers certainly have updated the code. pull that first and do rebase on mydevelop branch 
 # first go into develop branch for quick forward (assume there was NO change in develop branch)
 $> git checkout develop; git pull --rebase
 
 # if there are changes, do rebase on bug<num> 
 $> git checkout bug<num>; git rebase develop 
 $> ... fix any conflict during rebase 
  
 # submit for review 
 $> post-review --tracking-branch=origin/develop 
 # if post review to existing review request, do:
 $> post-review --diff-only -r <existing review id> --tracking-branch=origin/develop
  
 # after review shows no problem merge back to develop 
 $> git checkout develop; git merge --squash bug<num>; 
 # squash will merge a few commit into one. If there is only one commit, squash is not needed 
 
 # if --squash is used (combine a few commits from bug branch into one commit), need to run git commit again with real message 
 $> git commit -m "real message for the bug" 
 # before final push, do rebase pull again to make sure things are clean 
 $> git pull --rebase
 
 # if it's good to go, run push 
 $> git push
 
 # delete this old branch
 $> git branch -d bug<num> # delete this bug branch 
 
 

4. Revert a change

 $> git checkout -- <file> # if file has local changes but no confilict 
 $> git checkout HEAD <file> # if a file has conflict 

5. Revert a commited change but not in server

 $> git reset --soft HEAD^  # revert to prior the commit and keep the local change 
 $> git reset --hard HEAD   # discard everything in last commit 

6. Revert a change in server

 $> git revert HEAD 

7. Apply a patch

 $> git apply --stat <patch file>  # check status of the patch 
 $> git apply --check <patch file> # dry-run 
 $> git apply --apply <patch file> # real deal 
 
 # if the patch has signoff information, do: 
 $> git am --signoff --whilespace=fix <patch file>

8. Remove a file

 $> git rm <file name> 

9. Undo a commit and redo

 $> git commit ...
 $> git reset --soft HEAD^  # revert back to prior stage 
 $> edit other files 
 $> git add ....    
 $> git commit -c ORIG_HEAD
 This is most often done when you remembered what you just committed is incomplete,
 or you misspelled your commit message, or both. Leaves working tree as it was before "reset".
 
 Make corrections to working tree files.
 Stage changes for commit.  "reset" copies the old head to .git/ORIG_HEAD;
 redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead.

10. Recovering from a bad git-rebase

 $> git checkout bug123
 $> git reflog 
 # if the branch bug123 has bad rebase, and want to return to prior rebase state, do:
 $> git reset --hard head@{1}
分享到:
评论

相关推荐

    从 0 到 10 的 Git版本控制器入门精讲

    特别适合对git 有所耳闻但不曾学习过的朋友,6页的内容,从迷茫看到略懂。文档内附有截图和注册链接,简单易学,记忆深刻。 包括搭建仓库、生成公钥、配置推送地址、查看文件状态、代码提交、记录的获取、文件过滤、...

    Git使用整理

    Git版本控制器,简单使用Git版本控制器的整理

    Git 配置、合并、多人协作、使用手册

    Git最初是由Linux开发者Linus用了仅仅两周时间纯C语言编写而成,在编写完成之后就立马上手接管Linux源代码,不过在此之前Linux是由BitMover公司开发的BitKeeper分布式版本控制系统所管理源代码,它是商业收费的...

    GitExtensions-2.49.02-SetupComplete.msi

    Git Extensions是一款程序员经常使用Git图形化客户端,它的主要功能就是用来控制Git资料库,支持Windows资源管理器集成和Visual Studio集成。Git Extensions下载后打开安装包,一直点Next,安装全部组件。安装比较...

    Git-2.23.0/win64/32/mac 多文件

    *在最近的Git版本中,每个工作树的引用都暴露在外 refs / worktrees / &lt;wtname&gt; / hierarchy,表示工作树名称 必须是有效的refname组件。代码现在清理名称 给予工作树,确保这些参考文件格式正确。 *“git ...

    AutoItGitWrapper:Scite IDE 的包装器,支持提交到 GIT 存储库并启动差异程序

    确定 git 的命令语法 为 git 实现 ini 更改 将针对 SVN 的检查概括为用户可选择 扩展而不是重新实现包装器中已经内置的版本控制。 添加代码来处理 git。 验证打过补丁的 AutoIt3Wrapper.au3 和 .exe 都可以在全新...

    GitExtensions Wrapper:从 Matlab 中调用 GitExtensions-matlab开发

    从 Matlab 中调用 GitExtensions 的一个非常简单的包装器。 它适用于喜欢 GitExtensions GUI 的大多数功能(而不是 'git' 命令行标志)但希望从 Matlab 中控制它的人。 &gt; 混帐初始化 &gt; git 添加 &gt; git提交 等等 ...

    用于 Arduino微控制器平台 的 DES 和 Triples DES 加密和解密_C++_代码_相关文件_下载

    用于 Arduino 微控制器平台的 DES 和 Triples DES 加密和解密库 Arduino IDE 要安装库,下载文件并将其复制到 Arduino 开发环境的“libraries”文件夹中的子文件夹(例如“DES”)中。 该库在 Arduino Leonardo 上...

    gitslave:Git的多仓库协作超级项目-开源

    Gitslave是一个用于大型项目的协调版本控制的脚本,该脚本使用Git结合了来自多个独立存储库的代码。 gitslave比传统的git子模块更加灵活,它为命令行git提供了一个简单的包装器,该包装器管理带有“主” git存储库的...

    基于Git的配置管理器-Linux开发

    但vcsh-$ HOME的版本控制系统-多个Git $ HOME索引中的存储库30第二种方法简介联系方式30第二种方法虽然看起来似乎有大量的文档,并且对vcsh背后的概念的解释需要涉及git内部的一些细节,但是入门用vcsh非常简单。...

    git-search-replace:位于Git之上的实用程序,用于项目范围内的搜索和替换,也包括文件名

    git-search-replace是纯git之上的一个小实用程序,用于仅在git控制的文件上执行项目范围内的搜索和替换。 它将搜索应用于文件名及其内容。 搜索正则表达式的基本语法是Python。 与sed周围的hack bash脚本相比,它的...

    程序员为什么还要刷题-git-and-github:[git,github]

    使用文本编辑器 解释基本的 git 命令,如 init、add、commit、push、pull 和 clone 分叉和克隆远程存储库 回顾:Git 与 GitHub 和版本控制 Git 和 GitHub 有什么区别? Git 是一种软件版本控制工具,可在您的本地...

    gitrack:GitRack是一个脚本,用于跟踪您的项目由git控制的版本,当文件更改时,此脚本在Harvest(Currenlty)上创建一个计时器,将为当前工作分支创建新计时器

    吉轨GitRack是一个脚本,用于跟踪您的项目由git控制的版本,当文件更改时,此脚本在Harvest(Currently)上创建一个计时器,将为当前工作分支创建新计时器。为什么这个? 因此,您无聊每次都在为您正在执行的任务...

    gitkube:使用git push将docker镜像构建并部署到Kubernetes

    分叉此仓库并创建您自己的CRD +控制器+ git远程钩子,可以在Kubernetes集群上做事。 特征: 除了本机工具(git,kubectl)外,没有任何依赖关系 即插即用安装 简单的基于公钥的身份验证 RBAC就绪-使用RBAC控制对...

    ios-一个简单的分页控件,自己可以随便改,需要的看看,控制器数量自己定义.zip

    一个简单的分页控件,自己可以随便改,控制器数量自己定义,需要的看看,GitHub地址:https://github.com/yy342901/YYPageController.git 这里的下载大家别点了,直接去GitHub下载!!!这里的下载大家别点了,直接...

    buck:Brigade州长通用控制器

    定义您的CRD(或使用现有资源),并为控制器代码编写几行JavaScript。 BUCK使用的事件系统来处理Kubernetes事件。 并且它抽象化了建模和定义资源类型的过程。 它的超快速Rust服务器管理控制器(Kubernetes术语中的...

    gitt:战it中的Git

    通过阅读他们的日常生活,读者将不会学到只是如何使用Git,而是为什么版本控制系统很重要以及如何在组织内实现它们。书籍内容以下摘要显示了已完成的章节和待处理项目的列表。 GITT现在涵盖了所有21种最常用的Git...

    Mac_Sourcetree_3.2.1_225.zip

    SourceTree 是 Windows 和Mac OS X 下免费的 Git 和 Hg 客户端管理工具,同时也是Mercurial和Subversion版本控制系统工具。支持创建、克隆、提交、push、pull 和合并等操作。 SourceTree拥有一个精美简洁的界面,...

    gitium:通过简单的插件和存储库将所有WordPress代码保留在git上

    Gitium建于2013年,旨在为我们的客户提供一种更简单且无错误的方法,以将新的git版本控件集成到其代码管理流程中。 Gitium由 (一家托管WordPress托管提供商)的工程团队开发。 有关更多开源项目,请查看。 什么...

    etckeeper:在 git 中存储等

    它非常模块化和可配置,同时如果您了解使用版本控制的基础知识,那么使用起来也很简单。安全警告首先,一个重要的警告:通过将 /etc 签入版本控制,您正在创建 /etc/shadow 等必须保密的文件副本。 每当您拥有机密...

Global site tag (gtag.js) - Google Analytics