LoginSignup
0
1

More than 1 year has passed since last update.

git lfsの使い方メモ

Last updated at Posted at 2021-11-03

git lfsを使った際, リポジトリのpushまでが数回エラーで躓いたのでメモ

前提

gitの導入
git LFSの導入
導入などは こちら の通りに

リポジトリ作成からpushまで

(1)gitリポジトリの作成

git init

(2)LFSの設定

git lfs install

(3)LFSで管理したいファイルを設定
git add を行う前に実行する

git lfs track "${ファイル名}"

powershellでのファイル容量確認方法は こちら を参考に
linux, macだと find . -size +100M -ls で見るのが楽そう(参考)

(4)LFSの確認
(3)で管理対象に置いたファイルは .gitattributes に記述される
内容確認には以下コマンドを使用

git lfs track

(5)pushまで
通常の git push と同じ流れ

git add .
git commit -m "${commit message}"
git remote add origin ${httpsのgit URL}
git push origin main

うまくいかなかったこと

remote URLがSSHのものを利用している

httpsのURLに張り替えたところ動いた

git remote set-url origin ${https url}

先に add, commit をしてしまった

# addに関して
git rm --cached -r .

# commitに関して
git log
git reset -soft ${git logで調べた戻りたいコミット}

上記コマンドで git add, git commit の取り消しを行ったが git push 時に再度エラー発生...
結局gitリポジトリを削除し、再度 git init から行うことで解決

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1