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}
相关推荐
Git是一款强大的分布式版本控制系统,由Linus Torvalds在2005年为Linux内核开发而创建。它被广泛应用于软件开发,特别是在开源社区,因为它提供了高效、可靠的代码管理和协作功能。Git允许团队成员各自在本地工作,...
【Git 版本控制系统介绍】 Git 是一种分布式版本控制系统,由 Linux 内核的创始人林纳斯·托瓦兹于2005年开发,最初是为了更有效地管理 Linux 内核的开发。Git 的设计目标是速度、数据完整性以及支持非线性开发模式...
比如可以使用JIRA进行项目管理,Trac进行任务跟踪,而Git作为版本控制系统,使得整个开发流程更加高效和透明。 总的来说,Git由于其强大的版本管理功能和灵活的工作流支持,已经成为软件开发中不可或缺的工具。对于...
Java作为一种广泛使用的编程语言,其在各种项目中的应用无处不在,因此,了解如何在Java项目中有效利用Git版本控制系统显得尤为重要。本项目《基于Java语言的Git版本控制设计源码学习指南》正是为了满足这一需求而生...
总结起来,Git作为项目版本控制器,是软件开发中的关键工具,它使得代码版本管理变得简单高效。与GitHub的结合,进一步增强了团队协作和开源社区的互动。理解和熟练掌握Git及其与GitHub的使用,对于任何IT从业者都是...
基于Java和HTML技术的Git版本控制系统源码,是一个采用Java语言开发的版本控制软件,同时结合了HTML页面进行用户交互界面的设计。这种设计模式使得软件既具备了强大的后台处理能力,又提供了友好的前端操作界面,让...
GitKraken是一款针对Git版本控制系统的图形用户界面工具,适用于Ubuntu操作系统。版本6.5.1是该工具的一个较新版本,此版本为免费版,意味着用户可以无需支付费用即可享受到GitKraken的便利性。该软件以文件Git...
6. 强大的命令行工具:Git的命令行界面提供了丰富的命令,通过简单的指令就能完成复杂的版本控制操作。此外,还有许多图形化界面工具(如SourceTree、GitHub Desktop等)供不熟悉命令行的用户使用。 7. 协同工作:...
Git版本控制器,简单使用Git版本控制器的整理
Git由Linux的创始人Linus Torvalds在2005年开发,最初是作为Linux内核开发的工具,但很快它就独立于其初衷,成为一个广泛使用的版本控制平台。Git的特点在于它能在本地维护完整的版本历史记录,同时也支持与远程仓库...
### 分布式版本控制系统-Git详解 #### 版本控制的发展历程 版本控制技术随着软件开发的需求和技术的进步不断发展。从最初的本地版本控制系统到后来的集中式版本控制系统,再到现在的分布式版本控制系统,每一步...
Git是一款强大的分布式版本控制系统,尤其在开源社区中广泛使用,对于Android源码的管理非常得心应手。在Windows环境下,Git提供了图形化的客户端工具,使得开发者能够在Windows操作系统上便捷地进行版本控制操作。...
Git是当今最流行的分布式版本控制系统,广泛应用于软件开发和项目管理。Git的64位安装包确保了在64位操作系统上的高效运行,而Git-2.27.0是这个压缩包中提供的具体版本,它包含了最新的特性和优化。 Git的安装过程...
Git构建分布式版本控制器教程 Git是一款强大的开源分布式版本控制系统,由Linus ...希望这个教程能帮助你更好地理解和使用Git构建分布式版本控制器。在实际操作中,不断实践和探索,你会更加熟悉Git的强大功能。
Git for Windows 2017 最新版,Git-2.15.0 是Git的Windows适配版本,它为Windows用户提供了完整的Git功能,并且优化了在Windows环境下的使用体验。Git是一个分布式版本控制系统,由Linux之父Linus Torvalds开发,...
Git 的起源可以追溯到2005年,当时 Linux 内核项目的版本控制系统 BitKeeper 被其开发商收回了免费使用权,这导致了 Linux 开源社区需要寻找一个新的解决方案。由 Linux 的创始人 Linus Torvalds 领导的一群开发者...
Git是世界上最流行的分布式版本控制系统,广泛应用于软件开发和项目协作中。Git-2.19.2是Git的特定版本,此版本包含了自2.19.1以来的一系列更新和改进,旨在优化性能,增强功能,并修复已知的问题。在本篇中,我们将...
**SVN(Subversion)与Git是两种广泛使用的版本控制系统,它们在软件开发过程中起着至关重要的作用。本文将深入探讨这两个工具的基本概念、安装、配置以及日常使用方法。** ### SVN(Subversion) **1. SVN简介** ...
### 持续集成与Git:版本...通过上述介绍,我们了解了版本控制的基本概念、几种常见的版本控制系统之间的区别,以及如何使用Git来管理和协作开发项目。这些基础知识对于任何从事软件开发工作的人员来说都是非常重要的。
mplab X是Microchip公司官方提供的集成开发环境,支持多种微控制器的程序开发,同时git作为一款成熟的分布式版本控制系统,已经被广泛地运用在软件和硬件开发项目中,用于代码的版本控制和历史记录的维护。...