Skip to content

Instantly share code, notes, and snippets.

@luismrsilva
Last active July 11, 2020 03:41
Show Gist options
  • Save luismrsilva/008054ae01bcafd57a2420e1a854f7d3 to your computer and use it in GitHub Desktop.
Save luismrsilva/008054ae01bcafd57a2420e1a854f7d3 to your computer and use it in GitHub Desktop.
How to share a git repo on Técnico's AFS

How to share a git repo on Técnico's AFS

This is only for people with access to it, such as Técnico's students.

We will connect to sigma via SSH to make and share a directory using AFS ACL and init an empty git repository in it.

Connect to sigma and share a new directory

To connect to sigma, open a Terminal and run:

where ist1XXXXX is your username (IST-ID, the same you use on Fénix). The first time you connect you'll be asked if you trust the host key. Answer "yes". Use your IST-ID password when prompted.

You can check with the pwd command that you are on your home folder, on Técnico's AFS. If you want, you can do this on another subdirectory.

Create a directory for the repo and cd into it. It will be named my_shared_repo. The .git suffix is not needed. It's just used so we know it's a git repo.

$ mkdir my_shared_repo
$ cd my_shared_repo

Now, let's look at the ACL (Access Control List) for this directory.

$ fs listacl

You'll see that only your username (IST-ID) has permissions on the newly created directory.

To share the directory with another user i.e., give them all possible permissions, includng write ("w"), except administer ("a"):

$ fs setacl . ist1XXXXX rlidwk

Where ist1XXXXX is the IST-ID of the other user. Beware that not all IST-IDs are just "ist1" + "studentNumber".

To share with multiple users, do this step for each user.

Create Repo

To create a new empty repository:

$ git init --bare

Now, get the path of the directory where the git repo is:

$ pwd

This should show a path that starts with /afs/. Copy it to the clipboard (maybe paste it on a text editor).

You can now terminate the SSH connection to sigma (you can also just leave it open for now, just skip this step and open a new terminal):

$ exit

Clone the repo

Each of the users that needs access to the repo will need to do this step. I advice you to just copy the command, change the path, change the IST-ID for each user and send the respective version to each of them (and remind them to use their "Fénix" passowrd).

On your PC, cd to the directory where you want the repo to appear in and run:

$ git clone [email protected]:/afs/I/am/a/big/path/something

where ist1XXXXXX is either your IST-ID (or your colleague's) and /afs/I/am/a/big/path/something is the path to your repo's directory on AFS, that you should have copied earlier.

Beware: You may notice that somewhere in that path that you copied your IST-ID will appear. Do not change this. This is because the directory is inside your home. You only need to change the IST-ID before the @, since that's the username that's going to be used for authentication.

Also, you should make a fist commit before sharing this with your colleages. Each user should also setup their name and e-mail, which will be stored on each of their commits. Just as a reminder:

Configure name and e-mail on git

Each users needs to do this on their PC. I advise you to use your Técnico e-mail address.

$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"

Now you can use git to make commits. To to the first one:

$ git status
$ echo "Fancy Course Project" > readme.txt
$ git add readme.txt
$ git status
$ git commit -m "First commit"
$ git push

When you push and pull, etc. you will be asked for a password. Use the "Fénix" password.

Happy sharing! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment