Skip to content

Latest commit

 

History

History
264 lines (184 loc) · 6.22 KB

gitlfs_gitlab.md

File metadata and controls

264 lines (184 loc) · 6.22 KB

Git-LFS Notes

written by Nick Shin - [email protected]
this code found in this file is licensed under: Unlicense - http://unlicense.org/
and, is from - https://github.com/nickshin/CheatSheets/


Linux "server"

GETTING GIT-LFS WORKING WITH GIT

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
  • start tracking lfs files (per project)
cd .../project.git
git lfs track "*.zip"
git add .
git commit -m 'lfs tracking zip files'
- **NOTE**: this should also commit .gitattributes
  • push will be done after setting up the server (next)...

Set up a server that is LFS-API aware

sudo vi /etc/gitlab/gitlab.rb

  • to change the URL shown on webpages -- NOTE: MUST USE FQDN !!! postfix need this...
external_url 'http://gitbox.internal:8080'
# e.g. can use alt-port
# !!! keep an eye on `/var/log/gitlab/nginx/current`
# !!! if port already in use -- this will be spammed in logfile
  • enable Git LFS -- both are REQUIRED
gitlab_rails['lfs_enabled'] = true
gitlab_rails['lfs_storage_path'] = "/var/opt/gitlab/git-data/lfs-objects"
# -- OR --
gitlab_rails['lfs_storage_path'] = "/mnt/nas/lfs-objects"
# NO SYMLNKS
git_data_dir "/mnt/nas/git-data"
  • have the changes take effect
sudo gitlab-ctl reconfigure
  • BUGFIX: [GitLab Community Edition 8.4.4 9c31cc6]
    • if gitlab_rails['lfs_storage_path'] is under git_data_dir
sudo chgrp git /var/opt/gitlab/git-data/lfs-objects
  • for future reference...
sudo gitlab-ctl stop
    # do maintainence here...
sudo gitlab-ctl start
  • or "did you turn it off and on again..."
sudo gitlab-ctl restart

GitLab accounts

Setting up accounts on GitLab

  • open browser to ( should match external_url):
    • http://gitbox.internal
    • http://gitbox.internal:8080
username: root
password: 5iveL!fe
  • as admin create a [studio wide group]
  • as admin try creating a project
    • i.e. project path: http://gitbox.internal:8080/ -> [studio wide group] -> lfs-test
  • this does work... but mail will get sent to spam folder

    • add gitbox.internal to the DNS
    • NOTE admin can force confirm user
  • as normal make account (you know, for testing)

  • as admin add all (normal) users to [studio wide group]

MUST DO: setup ssh access (i.e. password-less connection)
ssh-keygen -t rsa -C "[email protected]" -f id_gitlab
cat id_gitlab.pub
# copy output to gitlab account [ profile settings -> ssh keys -> +add ssh key -> key ]
mv id_gitlab* ~/.ssh/.

Linux "clients"

pushing LFS projects to git server

  • if this is not yet set...
git remote add origin [email protected]:studio_wide_group/lfs-test.git
  • NOTE: LFS uses http(s) for everything: authentication, obtain the URL of the LFS file, and GET/PUT the LFS file
git config --add lfs.url "http://gitbox.internal/group/project.git/info/lfs"
  • credential caching MUST be used (especially when pushing/pulling more than 1 LFS file)
git config --global credential.helper 'cache --timeout=3600'
  • finally
git push -u origin master
notes about: project.git/info/lfs --> [info/lfs] --> i.e. lfs.url
git config --unset lfs.batch

CLONING

git clone [email protected]:group/project.git
	# this will return error messages...
	# but !!! **need to add lfs.url first** !!!

cd project
git config --add lfs.url "http://gitbox.internal/group/project.git/info/lfs"
git checkout -f HEAD

note to self...

misc - todo - to investigate - etc.

  • it seems that /var/opt/gitlab/git-data/lfs-objects will store ALL LFS objects...

  • meaning, they are mixed in with all of the projects...

  • need to see if there's an easy way to extract all objects by projects...

  • to redo everything (e.g. testing replication steps):

    • WARNING: this will NUKE existing GitLab
sudo gitlab-ctl cleanse
sudo apt-get install --reinstall gitlab-ce

Windows "clients"

WINDOWS (client) instructions

  • open browser to (internal) gitlab page: http://gitbox.internal

  • make an account for yourself

  • check your email for verification link

  • download windows installer for git and git-lfs

  • right click any folder -> select "Git Bash"

  • make "Git Bash" LFS aware

git lfs install
  • jic
git config --global user.name "First Last"
git config --global user.email "[email protected]"
git config --global credential.helper 'cache --timeout=3600'
  • !!! MUST DO !!!
git config --global credential.helper wincred
  • WARNING: on windows -- ssh key file MUST be id_rsa & id_rsa.pub
ssh-keygen -t rsa -C "[email protected]"
cat id_rsa.pub
# copy output to gitlab webpage [ profile settings -> ssh keys -> +add ssh key -> key ]
mv id_rsa* ~/.ssh/.

for each new project

  • MUST clone via GIT BASH (but can use any git GUI client after these steps)

  • fire up the ssh private/public key handler -- called the "agent"

eval "$(ssh-agent -s)"
- then follow [CLONING](#CLONING) steps
  • if errors here, might need to add hostname to c:\windows\system32\drivers\etc\hosts

finally

  • fire up your favorite git client and add this project
  • github's desktop client looks pretty easy/simple
  • atlassian's sourcetree also looks good