Changes for page Using Git
Last modified by Richard Kreissig on 2023/09/14 08:49
Summary
-
Page properties (2 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 2 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,0 @@ 1 -Guidelines - Content
-
... ... @@ -1,4 +1,4 @@ 1 -We use [[Git>>url:http://git-scm.com/||shape="rect"]] to manage our source code. Our [[ Stash>>url:http://git.rtsys.informatik.uni-kiel.de/||shape="rect"]]installation is the front end we use to manage our different Git repositories.1 +We use [[Git>>url:http://git-scm.com/||shape="rect"]] to manage our source code. Our [[Gitorious>>url:http://git.rtsys.informatik.uni-kiel.de/||shape="rect"]] installation is the front end we use to manage our different Git repositories. 2 2 3 3 This page will help you get started with Git and getting the KIELER sources. For more detailed information, see [[Git's official documentation>>url:http://git-scm.com/documentation||shape="rect"]]. The [[SVN Crash Course>>url:http://git-scm.com/course/svn.html||shape="rect"]] is probably a good place to start. For more in-depth information, see the [[Git Community Book>>url:http://book.git-scm.com/||shape="rect"]] or the [[Pro Git>>url:http://progit.org/book/||shape="rect"]] book. Furthermore, each office has a copy of another excellent book about Git, so you might as well go ahead and read it. This will help ease you in to some of the more advanced concepts of Git, which are a little hard to understand at first. If everything else fails, Miro and Tim will be more than happy to help you with Git and rant about how excellent of a system it is. For more information on Git Eclipse integration, see the [[EGit User's Guide>>url:http://wiki.eclipse.org/EGit/User_Guide||shape="rect"]]. 4 4 ... ... @@ -10,66 +10,51 @@ 10 10 11 11 = Checking Out KIELER = 12 12 13 -{{note}} 14 -You shouldn't need to check out anything manually if you have installed Eclipse using our Oomph setup. 15 -{{/note}} 16 - 17 17 KIELER is essentially a large heap of Eclipse plug-ins that aren't easy to find your way through as a new developer. The [[doc:Overview]] page has a nice overview of our sub-projects and what plug-ins belong where. This section will tell you how to get the KIELER sources. As for what plug-ins you will actually need to checkout, ask your advisor. 18 18 19 19 {{info title="Important Hint for Users Behind Firewalls"}} 20 - Repository accessvia SSHruns on port7999.Foraccessingtherepositoriesin read-onlymode,HTTP transfer is also possible, but not recommended.16 +The Git protocol runs on port 9418, and SSH runs on port 22. HTTP transfer is also possible in read-only mode, but is not recommended due to its bad performance. 21 21 {{/info}} 22 22 23 - CheckoutoftheGitrepositoryis possible eitherusing theSSHortheHTTPprotocol.WestronglyrecommendusingSSH; ifyoustillwantto useHTTP,omit theSSHkey creationanduploadin theinstructionsbelow.19 +You essentially have the choice of either checking out the KIELER sources using our project sets (preconfigured sets of plug-ins that are automatically imported into your Eclipse environment), or by selecting the plug-ins you want manually. 24 24 25 -1. If you don't have an SSH key yet, you have to create one. You can do this by:\\ 26 -1*. Creating one using the command {{code language="none"}}ssh-keygen{{/code}} on the command line. Simply type {{code language="none"}}ssh-keygen{{/code}}, confirm the default destination file ~~/.ssh/id_rsa, and choose whether to give a passphrase. If you have a passphrase, you need to enter it whenever you use your SSH key for the first time in a session. You can omit the passphrase, but that makes the key less secure. As result, the tool generates a private key ~~/.ssh/id_rsa, which has to be kept secret, and a public key ~~/.ssh/id_rsa.pub. 27 -1*. Using Eclipse to generate it. You can find this function under //Preferences - General - Network Connections - SSH2 - Key Management//. 28 -1. Register with [[Stash>>url:http://git.rtsys.informatik.uni-kiel.de||shape="rect"]] and upload your public SSH key (//Profile - SSH Keys - Add Key//). 29 -1. Copy one of the following repository URIs into the clipboard: {{code language="none"}}ssh://git@git.rtsys.informatik.uni-kiel.de:7999/KIELER/the_repo_to_clone.git{{/code}} where {{code language="none"}}the_repo_to_clone{{/code}} is either {{code language="none"}}pragmatics{{/code}} or {{code language="none"}}semantics{{/code}} (if in doubt, ask your adviser which of these you need). If you for whatever reason insist on using the less efficient HTTP protocol, use the following URI: (% class="nolink" %)http:~/~/youraccountname@git.rtsys.informatik.uni-kiel.de/scm/KIELER/the_repo_to_clone.git{{code language="none"}}{{/code}}(%%)) 30 -1. Open the //Git Repositories// view, right-click it, select //Paste Repository Path or URI//, select //ssh// connection protocol, //Next//, select master branch, //Next//, select destination directory (e.g. /home/<username>/shared/kieler), //Finish//. Wait for the repository to be downloaded to your computer. Note that the whole history of the repository will be stored in your local filesystem, which is pretty awesome. 31 -1. Right-click the //Working directory// entry in the //kieler// repository, select //Import Projects//, //Next//, select the projects that you want in your workspace, //Finish.// 21 +== Checkout Using Team Project Sets == 32 32 33 - Checkingoutonthecommandlineisdonewiththecommand{{codelanguage="none"}}gitclone<URI><local path>{{/code}}.InsteadoftheURIyou canalsouseapathtoalocalrepository,whichthen createsacloneof that repository.23 +If you need a specific subset of the KIELER plugins, select a suitable project set, copy its URL, and select //File - Import - Team - Team Project Set//. There are two versions of the project sets: 34 34 35 -== Adding an Existing Local Repository to EGit == 25 +* [[Project sets for the Git protocol>>url:http://rtsys.informatik.uni-kiel.de/%7Ekieler/projectsets/git/||shape="rect"]] (read-only; don't take these if you'll be actively developing KIELER code) 26 +* [[Project sets for the SSH protocol>>url:http://rtsys.informatik.uni-kiel.de/%7Ekieler/projectsets/git-ssh/||shape="rect"]] 36 36 37 - If youhavealready clonedtheKIELERrepository and areonlylookingforawaytoimportitintoEGit,followthese steps:28 +For access using the SSH protocol you first need to do steps 1 to 3 of the //manual checkout// section below. 38 38 39 -1. Click the button //Add an existing local Git Repository to this view// in the //Git Repositories// view and enter the local path. 40 -1. Import the plugin projects that you need. 30 +== Manual Checkout == 41 41 42 - ==ImportingPluginstotheEclipseWorkspace==32 +In case you only need read access, omit steps 1 to 4 and copy the following URI instead: 43 43 44 - Inthe GitRepositoryView, perform**Right-click> Import Projects...** onthe //Working directory// or //Plugins// folder. Hit//Next//. In the following dialog you can //Deselect all//and afterwards select the plugins that you need for your developingtask.34 +{{{ git://git.rtsys.informatik.uni-kiel.de/kieler/mainline.git}}} 45 45 46 - [[image:attach:git_repo_browser_import_plugins.png]]36 +Otherwise, follow these steps: 47 47 48 -For example, if you want to start **KIELER with SCCharts** you need to import 38 +1. If you don't have an SSH key yet, you have to create one. You can do this by: 39 +1*. Creating one using the command ssh-keygen on the command line. Simply type ssh-keygen, confirm the default destination file ~~/.ssh/id_rsa, and choose whether to give a passphrase. If you have a passphrase, you need to enter it whenever you use your SSH key for the first time in a session. You can omit the passphrase, but that makes the key less secure. As result, the tool generates a private key ~~/.ssh/id_rsa, which has to be kept secret, and a public key ~~/.ssh/id_rsa.pub. 40 +1*. Using eclipse to generate it. You can find this function under //Preferences - General - Network Connections - SSH2 - Key Management//. 41 +1. Register with [[Gitorious>>url:http://git.rtsys.informatik.uni-kiel.de||shape="rect"]] and upload your public SSH key (//Dashboard - Manage SSH keys - Add SSH key//). 42 +1. Ask a KIELER administrator to add you to the //kieler-dev// Gitorious team. 43 +1. Copy the repository URI git@git.rtsys.informatik.uni-kiel.de:kieler/mainline.git into the clipboard. 44 +1. Open the //Git Repositories// view, right-click it, select //Paste Repository Path or URI//, select //ssh// connection protocol, //Next//, select master branch, //Next//, select destination directory (e.g. /home/<username>/shared/kieler), //Finish//. Wait for the repository to be downloaded to your computer. Note that the whole history of the repository will be stored in your local filesystem, which is pretty awesome. 45 +1. Right-click the //Working directory// entry in the //kieler// repository, select //Import Projects//, //Next//, select the projects that you want in your workspace, //Finish.// 49 49 50 -1. ((( 51 -**all core plugins** (core.*) from the semantics and pragmatics repositories 52 -))) 53 -1. **all SCCharts plugins** (sccharts.*) from the semantics repository, **unless sccharts.prio.dependencies**,** sccharts.prio.dependencies.klighd**, **sccharts.prio.s**,** sccharts.prio.sim.s** 54 -1. **all required plugins** for the already imported ones 47 +In case you already checked out the repository over the read-only git protocol, but you want to be able to commit to the remote repository, open the //Git Repositories// view, right-click //kieler/Remotes/origin//, select //Configure Push//, and change the URI to the ssh variant. 55 55 56 - Asaresultyouwillhave the followingpluginprojectsinyour workspace:49 +Checking out on the command line is done with the command git clone <URI> <local path>. Instead of the URI you can also use a path to an existing repository, which then creates a clone of that repository. 57 57 58 -1. **From** the **pragmatics repo**: core, core.kgraph, core.kgraph.text, core.kgraph.text.ui, core.kivi, core.krendering, core.krendering.extensions, core.ui, kiml, kiml.formats, kiml.graphviz.dot, kiml.graphviz.layouter, kiml.service, kiml.ui, klay.layered, klighd, klighd.piccolo, klighd.ui, edu.umd.cs.piccolo 59 -1. **From** the **semantics repo**: core.annotations, core.annotations.edit, core.annotations.text, core.annotations.text.ui, core.kexpressions, core.kexpressions.edit, core.kexpressions.keffects, core.kexpressions.keffects.edit, core.kexpressions.keffects.ui, core.kexpressions.text, core.kexpressions.text.ui, core.kexpressions.ui, core.model, core.perspectives, core.product, kex, kex.ui, kico, kico.klighd, kico.ui, kitt, kitt.klighd, prom, s, s.sc, s.sim, s.sim.kivi, s.sim.sc, s.sim.sj, s.sj, s.ui, sc, sccharts, sccharts.edit, sccharts.editor, sccharts.eso, sccharts.kivi, sccharts.klighd, sccharts.prom, sccharts.s, sccharts.scg, sccharts.sim.c, sccharts.sim.s, sccharts.text, sccharts.text.ui, scg, scg.s, scl, sim.benchmark, sim.instructions, sim.kiem, sim.kiem.config, sim.kiem.ui, sim.kiem.ui.datacomponent, sim.kivi, sim.signals, sim.signals.ui, sim.syncsignalreset, sim.table, sjl, org.freemarker, org.json 51 +== Adding an Existing Local Repository to EGit == 60 60 61 - ===Troubleshooting/ResolvingPluginDependencies===53 +If you have already cloned the KIELER repository and are only looking for a way to import it into EGit, follow these steps: 62 62 63 -If there are errors in your workspace, they are most likely the result of missing plugins. To solve this, check if the MANIFEST.MF file of the project has error markers. **Import missing plugin dependencies** if required. 55 +1. Click the button //Add an existing local Git Repository to this view// in the //Git Repositories// view and enter the local path. 56 +1. Right-click the //Working directory// entry in the added repository, select //Import Projects//, //Next//, select the projects that you want in your workspace, //Finish.// 64 64 65 -[[image:attach:resolve_missing_plugins.png]] 66 - 67 -After all dependencies are solved and there are still errors, you should clean your workspace via **Project > Clean > All projects**. 68 - 69 -If there are errors in an xtend-gen folder you can delete this folder so that the contents are re-compiled. (It sometimes happens that this folder is not deleted as part of the clean.) 70 - 71 -There should not be any errors after all required plugins are imported and compiled correctly. 72 - 73 73 = Updating the Repository = 74 74 75 75 Your working copy must be clean before you can merge any updates into it. Therefore, always commit your changes locally before you pull. If you don't want to commit them into the master branch, commit them into a new branch. Note that pulling is the same as fetching remote changes and merging them into your local branch. Since a normal merge operation is involved, this can lead to conflicts, which need to be resolved as described below. Note that pulling always merges the remote changes into your current branch. If that's not what you want, checkout the correct branch first or just do a //fetch//. ... ... @@ -84,7 +84,7 @@ 84 84 85 85 Whenever branches are merged or rebased, conflicts can occur. They can be resolved by adjusting the state of your working copy, marking it as clean, and committing the changes. Conflicted files are modified so they contain both your version and the remote version. Edit them until all conflict areas are clean. In Eclipse this can be done by right-clicking the conflicted files - //Team - Merge Tool//. 86 86 87 -{{warning}} 72 +{{warning title="Warning"}} 88 88 If you try to pull from a remote repository or merge branches although you have local uncommitted changes, and the merge would affect the same files, Git leaves those files as they are, thus discarding the changes that would be made by the pull or merge operation. As a consequence, committing such a conflicted state would ignore the changes of the merged branch even if the commit graph looks like a regular merge has happened. Therefore keep in mind never to pull or merge with uncommitted changes. 89 89 {{/warning}} 90 90 ... ... @@ -103,8 +103,8 @@ 103 103 104 104 If another developer has pushed changes since the last time you have pulled from the server, your attempt to push your commits online may fail. In this case you need to pull the remote changes before you can push. Never use force pushing! ({{code language="none"}}git push -f{{/code}}) 105 105 106 -{{info title="Before you commit anything..."}}107 - Make sure you have set up your name and email address properly, as described on the [[doc:Configuring Eclipse]] page.91 +{{info title="Before you proceed..."}} 92 +Before you commit anything, make sure you have set up your name and email address properly, as described on the [[doc:Configuring Eclipse]] page. 108 108 {{/info}} 109 109 110 110 == Committing == ... ... @@ -128,58 +128,4 @@ 128 128 129 129 To push your commits on the command line, enter {{code language="none"}}git push{{/code}}. 130 130 131 -= Getting Earlier Versions of Files = 132 - 133 -If you want to revert //all// your local changes and get back to the previous repository state, use {{code language="none"}}git reset --hard{{/code}} or the //Reset// item in the EGit context menu. If you only want to revert some specific files, do one of the following: 134 - 135 -* Right click the files, click //Replace With//, click //HEAD Revision//. 136 -* Enter {{code language="none"}}git checkout <path>{{/code}} on the command line. 137 - 138 -By giving a branch, tag, or commit number in {{code language="none"}}git checkout <commit> <path>{{/code}}, you can get to any existing version of the files. If no path is given, {{code language="none"}}git checkout <commit>{{/code}} switches your whole working copy and index to the specified branch, tag, or commit number. If {{code language="none"}}git reset{{/code}} is given a commit number, the current branch is modified to point at the given commit. 139 - 140 -{{warning}} 141 -This is a brute force modification, and you probably won't be able to push the new branch 142 -{{/warning}} 143 - 144 -= Cleaning Your Working Directory = 145 - 146 -In case the working directory is messed up with unstaged files, which are not affected by {{code language="none"}}git reset --hard{{/code}}, a clean up is achieved by means of {{code language="none"}}git clean -f{{/code}}. The additional switch {{code language="none"}}-d{{/code}} applies this to directories, respectively. Hence, {{code language="none"}}git reset{{/code}} followed by {{code language="none"}}git clean{{/code}} act like {{code language="none"}}svn revert{{/code}}. 147 - 148 -{{code language="none"}}git clean -X{{/code}} removes only the files that are ignored by Git, that is mainly the .class files generated by the Java compiler. A full rebuild is required afterwards. 149 - 150 -= Branching and Merging = 151 - 152 -Branches are used to structure your development and are an essential tool for effective work in the KIELER team. Read the [[doc:Source Code Management]] page if you haven't yet understood what branches are good for. 153 - 154 -== Creating a Branch == 155 - 156 -Do one of the following: 157 - 158 -* Right-click the KIELER repository in the //Git Repositories// view, click //Switch To//, click //New Branch//. 159 -* On the command line, enter {{code language="none"}}git branch <name>{{/code}}. In this case, the new branch is not active; if you want to activate the new branch while creating it, enter {{code language="none"}}git checkout -b <name>{{/code}}. 160 - 161 -In either case the new branch starts at the current position of your working copy, i.e. it branches from the current branch you are on. In order to branch from a different position, either check out that other branch first or select it as //source ref// in the EGit wizard (on the command line simply type git branch <name> <start_point>). 162 - 163 -== Switching to Another Branch == 164 - 165 -Do one of the following: 166 - 167 -* Navigate to the branch in the KIELER repository in the //Git Repositories// view, right click it, click //Checkout//. 168 -* On the command-line, enter {{code language="none"}}git checkout <name>{{/code}}. 169 - 170 -Note that your local uncommitted changes are transferred when switching the current branch. 171 - 172 -== Merging Branches == 173 - 174 -You always merge another branch into the current branch. Therefore you first have to checkout the target branch prior to merging. Then, do one of the following: 175 - 176 -* Navigate to the source branch in the //Git Repositories// view, right-click it, click //Merge.// 177 -* On the command line, enter {{code language="none"}}git merge <source_name>{{/code}}. 178 - 179 -This creates a new //merge commit//, i.e. a commit with two source commits, and the target branch (the one you're currently on) contains all changes that have been done in the source branch (the one selected for merge). The source branch is not modified. A merge is done implicitly when pulling: assuming you're on branch master, the command git pull origin master is the same as git fetch origin followed by git merge origin/master, where origin/master is the remote tracking branch for master. 180 - 181 -= Working With Multiple Remote Repositories = 182 - 183 -Stash allows the creation of personal server-side clones of the KIELER repository, which is highly encouraged as described on the [[doc:Source Code Management]] page. When working with such clones, it is often necessary to synchronize the different server-side repositories with the local one. Git supports this by allowing to configure multiple //remotes// in the local repository. On the command line this is done simply by entering git remote add <name> <url>, where <name> is an arbitrary local identifier for the remote repository. For example, a remote named origin is automatically created when a local repository clone is created through git clone <url>. 184 - 185 -When you push or pull branches, simply select the remote you wish to interfere with. Pulling is done by {{code language="none"}}git pull <remote> <branch>{{/code}}, and pushing is done by {{code language="none"}}git push <remote> <branch>{{/code}}. 116 +
- git_repo_browser_import_plugins.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -50.2 KB - Content
- resolve_missing_plugins.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -199.9 KB - Content
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -88478 71 +884798 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/88478 7/Using Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/884798/Using Git