Changes for page Using Git
Last modified by Richard Kreissig on 2023/09/14 08:49
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- 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 ... ... @@ -13,21 +13,41 @@ 13 13 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. 14 14 15 15 {{info title="Important Hint for Users Behind Firewalls"}} 16 - 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. 17 17 {{/info}} 18 18 19 - 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. 20 20 21 -1. If you don't have an SSH key yet, you have to create one. You can do this by:\\ 22 -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. 23 -1*. Using Eclipse to generate it. You can find this function under //Preferences - General - Network Connections - SSH2 - Key Management//. 24 -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//). 25 -1. Copy the repository URI into the clipboard: {{code language="none"}}ssh://git@git.rtsys.informatik.uni-kiel.de:7999/KIELER/mainline.git{{/code}} (if you insist in using HTTP: (% class="nolink" %)http:~/~/youraccountname@git.rtsys.informatik.uni-kiel.de/scm/KIELER/mainline.git{{code language="none"}}{{/code}}(%%)) 21 +== Checkout Using Team Project Sets == 22 + 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: 24 + 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"]] 27 + 28 +For access using the SSH protocol you first need to do steps 1 to 3 of the //manual checkout// section below. 29 + 30 +== Manual Checkout == 31 + 32 +In case you only need read access, omit steps 1 to 4 and copy the following URI instead: 33 + 34 +{{{ git://git.rtsys.informatik.uni-kiel.de/kieler/mainline.git}}} 35 + 36 +Otherwise, follow these steps: 37 + 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. 26 26 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. 27 27 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.// 28 28 29 - Checkingoutonthecommand lineisdonewiththecommand{{codelanguage="none"}}gitclone<URI> <localpath>{{/code}}.InsteadoftheURI youcan alsousea path toa local repository,whichthen creates a cloneofthatrepository.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. 30 30 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. 50 + 31 31 == Adding an Existing Local Repository to EGit == 32 32 33 33 If you have already cloned the KIELER repository and are only looking for a way to import it into EGit, follow these steps: ... ... @@ -100,7 +100,7 @@ 100 100 * Right click the files, click //Replace With//, click //HEAD Revision//. 101 101 * Enter {{code language="none"}}git checkout <path>{{/code}} on the command line. 102 102 103 -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,{{codelanguage="none"}}git checkout <commit>{{/code}}switches your whole working copy and index to the specified branch, tag, or commit number. If{{codelanguage="none"}}git reset{{/code}}is given a commit number, the current branch is modified to point at the given commit.123 +By giving a branch, tag, or commit number in git checkout <commit> <path>, you can get to any existing version of the files. If no path is given, git checkout <commit> switches your whole working copy and index to the specified branch, tag, or commit number. If git reset is given a commit number, the current branch is modified to point at the given commit. 104 104 105 105 {{warning}} 106 106 This is a brute force modification, and you probably won't be able to push the new branch ... ... @@ -108,43 +108,10 @@ 108 108 109 109 = Cleaning Your Working Directory = 110 110 111 -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{{codelanguage="none"}}-d{{/code}}applies this to directories, respectively. Hence,{{codelanguage="none"}}git reset{{/code}}followedby {{code language="none"}}git clean{{/code}}act like{{code language="none"}}svn revert{{/code}}.131 +In case the working directory is messed up with unstaged files, which are not affected by git reset ~-~-hard, a clean up is achieved by means of git clean -f. The additional switch -d applies this to directories, respectively. Hence, git reset + git clean act like svn revert. 112 112 113 - {{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.133 +git clean -X 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. 114 114 115 115 = Branching and Merging = 116 116 117 -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. 118 - 119 -== Creating a Branch == 120 - 121 -Do one of the following: 122 - 123 -* Right-click the KIELER repository in the //Git Repositories// view, click //Switch To//, click //New Branch//. 124 -* 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}}. 125 - 126 -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>). 127 - 128 -== Switching to Another Branch == 129 - 130 -Do one of the following: 131 - 132 -* Navigate to the branch in the KIELER repository in the //Git Repositories// view, right click it, click //Checkout//. 133 -* On the command-line, enter {{code language="none"}}git checkout <name>{{/code}}. 134 - 135 -Note that your local uncommitted changes are transferred when switching the current branch. 136 - 137 -== Merging Branches == 138 - 139 -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: 140 - 141 -* Navigate to the source branch in the //Git Repositories// view, right-click it, click //Merge.// 142 -* On the command line, enter {{code language="none"}}git merge <source_name>{{/code}}. 143 - 144 -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. 145 - 146 -= Working With Multiple Remote Repositories = 147 - 148 -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>. 149 - 150 -When you push or pull branches, simply select the remote you wish to interfere with. Pulling is done by git pull <remote> <branch>, and pushing is done by git push <remote> <branch>. 137 +
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -4 3253841 +884804 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/4 325384/Using Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/884804/Using Git