---+ Creating a Git Repo Git repositories allow for many types of workflows, centralized or decentralized. Before creating your repo, decide which steps to follow:<br /><br /> <img width="382" alt="Git_Flowchart.png" src="%ATTACHURLPATH%/Git_Flowchart.png" height="421" /> ---++ Create A Local Repository If you will be working primarily on a local machine, you may simply create a git repo by using =cd= to change to the directory you wish to place under version control, then typing: <verbatim>git init</verbatim> To initialize a git repo in that directory. From then on, you can run git commands in that directory. ---++ Create A Remote Repository If you will be working with your code primarily on patas, you will likely want to create your initial repository there. 1 =ssh= to patas.ling.washington.edu 1 <span class="WYSIWYG_TT">cd </span>to the directory you wish to place under version control 1 type "<span class="WYSIWYG_TT">git init</span>" in this directory. ---+++ Cloning the Remote Repository If you wish to maintain a local copy of your code, you can clone the repository from patas by doing the following: 1 create and cd into the directory you want to store the copy of the repository in 1 <p>type:</p> <verbatim>git clone ssh://<YOUR_USERNAME>@patas.ling.washington.edu/<PATH_TO_FILE> <DESTINATION_DIR></verbatim> <br />for instance, if your username is "clmastudent" and the repo on patas is at ~/mycode, and you are already in the desired directory to store the copy ("."), you would type:<br /><br /> <p> </p> <verbatim>git clone ssh://firstname.lastname@example.org/~mycode .</verbatim> 1 After entering your ssh password, you should have a copy of the entire repo in whichever directory you chose to clone it to. ---++ Create a Shared Repository on Patas If you will be working with a group, using Patas as a centrally-located server to coordinate your checkins is a good idea, but takes some setting up. 1 You will need to send a request to [[mailto:email@example.com][firstname.lastname@example.org]] requesting that a group be created for the patas account names in your group. This will allow your group members read/write access to your files, without making them readable to everyone. 1 You may also wish to request a directory be made for your group in the =/workspace= directory on the server. This space is intended specifically for shared projects. 1 Once inside the desired directory, you will need to type:<br /> <verbatim>git init --shared=group</verbatim> this will create a git repo in which all group members are able to check in code ("Push" to, in Git terms) If you already have a repository that wasn't created with --shared=group, you can convert it by doing the following: 1 Edit the repository's "config" file (found in the main directory of the repository if it's bare, or in the .git folder if it's non-bare.) 1 Add a line under [core] with "sharedRepository=true" 1 Run "chmod -R g+w" on the repository's main directory. ---+++ "Bare" repositories By default, the shared repository has a working copy just like one on your local machine. git will complain if you do any remote operations that might make this working copy go out of sync, such as "git push origin master," with a message like the following: <verbatim>remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD.</verbatim> The solution is to make your shared repository a "bare" repository, with no working copy. The git FAQ has a good [[https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F][example of how to convert a non-"bare" repository]] to a "bare" one. For more information, see the description of "--bare" in the git-clone manpage or [[http://stackoverflow.com/questions/5540883/whats-the-practical-difference-between-a-bare-and-non-bare-repository][this stackoverflow thread]]. These instructions seem to sometimes convert a shared repository into a non-shared one, causing only one group member to be able to push; if you have this problem, you can correct it with the instructions at the end of the section above.
2011-05-04 - 18:42
Flowchart for which type of git repo to create.
ore topic actions
Topic revision: r7 - 2013-02-07 - 18:29:32 - brodbd
Create New Topic
Copyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Terms & Conditions