Difference: GitSetup (1 vs. 2)

Revision 22012-03-31 - brodbd

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Creating a Git Repo

Line: 35 to 35
 
  1. This file will be a script file that will be executed whenever someone successfully pushes to the repository. It may be any type of script, but the following script will make certain the permissions for the files in your repository allow access to all of your group members:
    #!/bin/bash
    
    # Make sure all files are set to be owned by the group.
Changed:
<
<
chown -R :
>
>
chown -R --from=`whoami` :
  # Set all directories to 770 (Read/Write/List for owner and group members, noone else)
Changed:
<
<
find -type d -exec chmod 770 {} \;
>
>
find -user `whoami` -type d -exec chmod 770 {} \;
  # Add read/write permissions for owner and group (preserve executable permission) and remove permissions for others.:
Changed:
<
<
find -type f -exec chmod ug+rw {} \; -exec chmod o-rwx {} \; Where <GROUP_NAME> and <SHARED_DIRECTORY> are replaced with the group name you should have received from linghelp, and the root directory of your repository, respectively.
  1. After this file is created, be sure to perform:
    chown :<GROUP_NAME> hooks/post-receive
    chmod g+x hooks/post-receive
    to ensure that the script is executable by each group member when performing the PUSH.
>
>
find -user `whoami` -type f -exec chmod ug+rw {} \; -exec chmod o-rwx {} \; Where <GROUP_NAME> and <SHARED_DIRECTORY> are replaced with the group name you should have received from linghelp, and the root directory of your repository, respectively.
  1. After this file is created, be sure to perform:
    chgrp <GROUP_NAME> hooks/post-receive
    chmod g+rx hooks/post-receive
    to ensure that the script is executable by each group member when performing the PUSH
 
META FILEATTACHMENT attachment="Git_Flowchart.png" attr="" comment="Flowchart for which type of git repo to create." date="1304534556" name="Git_Flowchart.png" path="Git Flowchart.png" size="43690" stream="Git Flowchart.png" tmpFilename="/usr/tmp/CGItemp62948" user="rgeorgi" version="1"

Revision 12011-05-04 - rgeorgi

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

Creating a Git Repo

Git repositories allow for many types of workflows, centralized or decentralized. Before creating your repo, decide which steps to follow:

Git_Flowchart.png

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:

git init

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
  2. cd to the directory you wish to place under version control
  3. type "git init" 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
  2. type:

    git clone ssh://<YOUR_USERNAME>@patas.ling.washington.edu/<PATH_TO_FILE> <DESTINATION_DIR>

    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:

    git clone ssh://clmastudent@patas.ling.washington.edu/~mycode .
  3. 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 linghelp@uw.edu 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.
  2. Once inside the desired directory, you will need to type:
    git init --shared=group
    this will create a git repo in which all group members are able to check in code ("Push" to, in Git terms)

Dealing with File Permissions

Due to a peculiarity in the way file permissions behave between patas and other clients, you will also need to set up a script to run chown and chmod commands when files are checked in, otherwise they might only be readable by the group member that checked them in. To do this:

  1. Inside your git repo (it may be inside a subdirectory titled ".git/"), there is a subdirectory entitled "hooks/"
  2. You will want to create a file inside the hooks directory called "post-receive".
  3. This file will be a script file that will be executed whenever someone successfully pushes to the repository. It may be any type of script, but the following script will make certain the permissions for the files in your repository allow access to all of your group members:
    #!/bin/bash
    
    # Make sure all files are set to be owned by the group.
    chown -R :<GROUP_NAME> <SHARED_DIRECTORY>
    
    # Set all directories to 770 (Read/Write/List for owner and group members, noone else)
    find <SHARED_DIRECTORY> -type d -exec chmod 770 {} \;
    
    # Add read/write permissions for owner and group (preserve executable permission) and remove permissions for others.:
    find <SHARED_DIRECTORY> -type f -exec chmod ug+rw {} \; -exec chmod o-rwx {} \;
    Where <GROUP_NAME> and <SHARED_DIRECTORY> are replaced with the group name you should have received from linghelp, and the root directory of your repository, respectively.
  4. After this file is created, be sure to perform:
    chown :<GROUP_NAME> hooks/post-receive
    chmod g+x hooks/post-receive
    to ensure that the script is executable by each group member when performing the PUSH.

META FILEATTACHMENT attachment="Git_Flowchart.png" attr="" comment="Flowchart for which type of git repo to create." date="1304534556" name="Git_Flowchart.png" path="Git Flowchart.png" size="43690" stream="Git Flowchart.png" tmpFilename="/usr/tmp/CGItemp62948" user="rgeorgi" version="1"
 
This site is powered by the TWiki collaboration platformCopyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Privacy Statement Terms & Conditions