View
1
Download
0
Category
Preview:
Citation preview
RMGStudyGroupBasicsofGit
NathanYee2/23/2015
1
KeyURLs
§ http://www.github.com/GreenGroup§ Git repositoryofallRMG-Py code
§ http://greengroup.github.io/RMG-Py/§ OnlineversionofthecurrentRMG-Py documentation
§ http://rmg.mit.edu§ OfficialRMG-Py documentation,thermodynamicsandkineticsdatabasebrowser,andwebtools
§ http://dev.rmg.mit.edu§ Developmentalversionofrmg.mit.edu withlatestfeaturesandpotentialbugs
§ Touse,add18.172.0.124 dev.rmg.mit.edu tohostsfileinyouroperatingsystem
2
Git
§ Git isaversioncontroltool§ Multipleuserscaneditmultiplecopiesofcode§ Singleusercancreatemultiplebranchesforasinglerepository
§ Onlinedetailedtutorial:§ http://git-scm.com/book
§ Wheretofindprogramstohelpyouusegit:§ http://git-scm.com/downloads
3
Gettingstarted:createalocalrepo
Twocommonscenarios:(onlydooneofthese)a) Tocloneanalreadyexistingrepotoyourcurrent
directory:$ git clone <url> [local dir name]Thiswillcreateadirectorynamedlocaldir name,containingaworkingcopyofthefilesfromtherepo,anda.git directory(usedtoholdthestagingareaandyouractualrepo)
b) TocreateaGit repoinyourcurrentdirectory:$ git initThiswillcreatea.git directoryinyourcurrentdirectory.Thenyoucancommitfilesinthatdirectoryintotherepo:$ git add file1.java$ git commit –m “initial project version”
4
BasicGit Workflow
1. Modify filesinyourworkingdirectory.2. Stage files,addingsnapshotsofthemto
yourstagingarea.3. Makeacommit,whichtakesthefilesas
theyareinthestagingareaandstoresthatsnapshotpermanentlytoyourGit directory.
5
Git filelifecycle
Notes:Ifaparticularversionofafileisinthegit directory,it’sconsideredcommitted.Ifit’smodifiedbuthasbeenaddedtothestagingarea,itisstaged.Ifitwaschanged sinceitwascheckedoutbuthasnot beenstaged,itismodified.
6
LocalCommits
1. ‘git status’tocheckwhichfilesaremodified-’git diff<filename>’showsline-by-linechanges
2. ‘git add<filename>’stagesalldesiredfiles3. ‘git commit’createsnewsnapshotofstagedfiles
andaddstothehistory4. ‘git log’pullsuphistoryofbranch;shouldseeyour
latestcommit
7
WritingCommitMessages
§ Firstlineis<80charactersummary§ Followedbydetaileddescription
§ Listofalladditions/changes§ Motivation§ Implementationdetails
§ Examplesofbadgit messages:§ “Typo”§ “Adddatabaseentries”
§ Aftersavingmessageauniquecommitstringiscreatedforeachentry
8
Git Branches
§ Branchesstartanewhistorytomakeexperimentalfeatures
§ Allowsexperimentationwithoutfearof“messingupthecode”
9
CommandsusedwithBranches
§ Git branch:pullsupalistofallthebranches§ Git branch<newbranch>:forksanewfromthecurrenthead
10
Fromthiscommit:Git branchnice_feature
CommandsusedwithBranches
§ Git checkout<location>:movestheheadtolocation(canbeacommitstringorbranchname)
§ Git merge<branch>:mergesallcommitsfrombranch
11
Git checkoutabcd1234bringsyouherefrom
anywhereelse
Fromhere:Git mergenice_featureCommitsthenicefeature
tomaster
AdvancedHistoryControl:Rebase
§ Normallywhenmerging:makeanewcommitthatincorporatesallchanges
§ Fromexperiment:Git rebasemastermergesandchronologicallyreorderscommits
12
FullControl:Git rebaseinteractive
§ Git rebase–i <commitstring>:opensinteractiveGUIthatallowsfullrewritingofhistory§ Deleteorreordercommits§ Squashcommitstogether§ Makechangestoacommit§ Rewritecommitmessages
§ WARNING:donotusethistorewritehistoryyouhavepushedtoofficial
13
GreenGroupRepos
14
OfficialGreenGroupRepo
• https://github.com/GreenGroup/• Forofficialdistribution
PersonalGithub Repo
-Sharingdevelopmentswithotherusers-Backupofin-progresscode
LocalRepositories
-Runningjobs-Codedevelopmentanddebugging
Gitp
ush
PullRe
quest
Gitpull Gitpull
SettingupRemoteRepos
§ Git remoteadd<remotename><url>
§ IfyouoriginallyforkedfromGreenGroup official:§ Git remoterenameoriginofficial§ CreateyourownforkonGithub andnameorigin
15
Pulling/PushingCommits
§ Eachrepohasitsownbranches§ Commandsforpullingandpushingcallbranches§ Mostcommoncall:git pullofficialmaster§ Forpushing:git pushoriginnew_feature
§ Goodideatotrytokeepbranchnamesconsistent
16
KeepingOfficialRepoClean
§ Topushacommittoofficial:1. CleanupyourcommithistorywithGit rebase–i
<firstnewcommit>2. Checkthatyourcurrentcommitisupdatedupto
theofficialGit pull–rebaseofficialmaster3. PushtoyourpersonalGitHubrepo:Git push
originnew_feature4. Makeformalpullrequest fromyourGitHub
Repo
17
CommonGit commands
18
YoucandoallofthisusingGit-cola:apowerfulGUIinterface
Commitorrevertspecificlines.Stagefilesandwritecommitmessagesgraphically.Amendcommits.
19
Git-cola:apowerfulGUInterface
Visualizepastcommithistoryandrepositorybranches.(Greatfortrackingspecificcodechanges.)
AvailableforWindows,Mac,andLinux!
20
Recommended