ギャバンITサービス
お菓子の家が作れるシステムエンジニアです

vscodeで「gitのリポジトリがありません」ってよ

windowsのvscodeで、何かの拍子にたまに起きる。 フォルダあるのに何言うてんねん、ってなる。 ファイルサーバはubuntu20。 実際.gitのフォルダは存在する。 たぶんフォルダのアクセス権とかセキュリティ設定かなって類推する。 ubuntu20でgit branchってやってもわからんかったけど、windows側でgit bashで開いたらこんなんなってた。 unsafe repositoryって、もー、なんやねん、うっざいなぁ。 さっさとvscodeで編集したいのになぁ。 fatalの表記にこう打てって書いてある。 1 git config --global --add safe.directory '%(prefix)///nafslinux.intra.gavann-it.com/nariGVIS/etc/gvis-memos2022' そのまま打つと、gitのリポジトリ読めるようになってgitgraphもちゃんと表示できるようになった。 何なんやろ。

gitlab利用

docker-composeでgitlab運用するメモ。 初めて使ったときはまだcentos動いててdockerも使ってなくて、仮想マシンを1つ作ってインストールしてた。 gitlabのインストール | ギャバンITサービス gavann-it.com その後、地味にgitの練習したっけ。 gitの基礎 | ギャバンITサービス gavann-it.com 今じゃソース管理だけじゃなく、この文章とか普段利用してるドキュメント類の維持管理で使わせてもらってる。 コマンドライン使うことはなくなってvscodeで書いてはcommitし、google cloudに持っていってpushしてる。 dockerで動かしてて、年に1回はgitlabコンテナを作り直してるのでそのメモ。 gitlabをdockerコンテナで使う いつもどおり、失敗しても何度でも作り直せる。 バージョン狙い撃ちして使える。 dockerhubに公開ページがあって、今の最新だけじゃなく履歴を教えてくれる。 ここでdocker-compose.ymlにタグ指定で使うバージョン番号を確認する。 hub.docker.com docker-compose.yml用意する 今年使ってる分の定義。 全体定義は このへん にある。 1 2 3 4 5 6 7 8 SVgitlab2022: image: gitlab/gitlab-ce:14.6.3-ce.0 ports: - 10881:80 volumes: - ./nariDockerDat/sv_gitlab2022/config:/etc/gitlab - ./nariDockerDat/sv_gitlab2022/logs:/var/log/gitlab - ./nariDockerDat/sv_gitlab2022/data:/var/opt/gitlab 来年用の定義。バージョンを今の最新に近いのにして、データ置き場もカラにして用意しておく。 ...

 ⭐️

gitの基礎

ホンマの最初はgitlabが動くvmを作ったけど、普段はgoogle cloudのdockerコンテナでgitlab動かして使ってる。 djangoのソースやドキュメントを維持するために使ってるんやけど、最初の頃にgit操作勉強したときのメモ。 クローンからブランチ作成まで勉強させてもらった。 参考URL クローン git clone (URL.git) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 nari@nariUbun18:~/Desktop$ git clone http://nawhlinux.intra.gavann-it.com:10080/naritomi/memos.git Cloning into 'memos'... remote: Enumerating objects: 1258, done. remote: Counting objects: 100% (1258/1258), done. remote: Compressing objects: 100% (939/939), done. remote: Total 1258 (delta 269), reused 1256 (delta 268) Receiving objects: 100% (1258/1258), 814.57 MiB | 20.89 MiB/s, done. Resolving deltas: 100% (269/269), done. Checking out files: 100% (1092/1092), done. nari@nariUbun18:~/Desktop$ ls memos nari@nariUbun18:~/Desktop$ cd memos/ nari@nariUbun18:~/Desktop/memos$ ls 01_URL_ショートカット集 09_linuxノウハウ 16_KVMノウハウ 23_git 02_windowsノウハウ 10_VBAノウハウ 17_xamppノウハウ 24_AWS 03_dotnetノウハウ 11_電話ノウハウ 18_oracleノウハウ 25_GoogleCloud 05_vmwareノウハウ 12_LANノウハウ 19_c 26_docker 06_奉行ノウハウ 13_全銀手順 20_routerノウハウ README.md 07_hyperV-VirtualPCノウハウ 14_メール 21_teratadaノウハウ 08_terastationノウハウ 15_MySQLノウハウ 22_SQLノウハウ nari@nariUbun18:~/Desktop/memos$ ブランチ一覧確認とブランチ切り替え git branch -a git checkout -b (branch name)) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 nari@nariUbun18:~/Desktop/memos$ git branch -a * master remotes/origin/20190923 remotes/origin/2nd remotes/origin/HEAD -> origin/master remotes/origin/master nari@nariUbun18:~/Desktop/memos$ git checkout -b 20190926 Switched to a new branch '20190926' nari@nariUbun18:~/Desktop/memos$ git branch -a * 20190926 master remotes/origin/20190923 remotes/origin/2nd remotes/origin/HEAD -> origin/master remotes/origin/master nari@nariUbun18:~/Desktop/memos$ gitログの確認 git log –oneline 1 2 3 4 5 6 7 nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git log --oneline 316450c (origin/master, origin/HEAD, master) Merge branch '20190923' into 'master' c401f18 (origin/20190923) 1)ノウハウを追加 a4c6680 (origin/2nd) 追記してコミット 35ff8ff Ubuntu setup1 c553dc1 Add README.md nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ ファイル/フォルダを追加 git add (folder or filename)) 1 2 3 4 5 6 7 8 9 nari@nariUbun18:~/Desktop/memos$ cd 23_git/ nari@nariUbun18:~/Desktop/memos/23_git$ ls -l 合計 6556 drwxr-xr-x 3 nari nari 4096 9月 26 04:35 git -rw-r--r-- 1 nari nari 6704532 9月 26 04:35 git.zip drwxrwxr-x 2 nari nari 4096 9月 26 04:50 gitCommand nari@nariUbun18:~/Desktop/memos/23_git$ nari@nariUbun18:~/Desktop/memos/23_git$ git add gitCommand nari@nariUbun18:~/Desktop/memos/23_git$ ファイル/フォルダを削除 git rm (folder or filename) ブランチをコミット git commit -a -m “任意のコメント” 1 2 3 4 5 nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git commit -a -m "gitコマンドの追記" [20190926 afd002e] gitコマンドの追記 1 file changed, 73 insertions(+) create mode 100644 23_git/gitCommand/gitCommand.txt nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ コミットのコメントを修正 git commit –amend -m “任意のコメント” 1 2 3 4 5 6 7 8 9 10 11 12 13 nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git commit --amend -m "GITコマンドの追記" [20190926 505c6b3] GITコマンドの追記 Date: Thu Sep 26 05:06:13 2019 +0900 1 file changed, 73 insertions(+) create mode 100644 23_git/gitCommand/gitCommand.txt nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ git log --oneline 505c6b3 (HEAD -> 20190926) GITコマンドの追記 316450c (origin/master, origin/HEAD, master) Merge branch '20190923' into 'master' c401f18 (origin/20190923) 1)ノウハウを追加 a4c6680 (origin/2nd) 追記してコミット 35ff8ff Ubuntu setup1 c553dc1 Add README.md nari@nariUbun18:~/Desktop/memos/23_git/gitCommand$ コミットのコメント複数行を修正 git commit –amend ※専用エディタが起動する ...

gitlabのインストール

初めて環境作ったときのコマンドライン。 当時はvmwareでcentos7を立てて作ったけど、今はdockerコンテナで動いている。 インストール curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 [nari@linux4ruby ~]$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6463 0 6463 0 0 7526 0 --:--:-- --:--:-- --:--:-- 7532[sudo] nari のパスワード: Detected operating system as centos/7. Checking for curl... Detected curl... Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=centos&dist=7&source=script done. Installing pygpgme to verify GPG signatures... 読み込んだプラグイン:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * epel: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * ius: mirrors.kernel.org * updates: ftp.jaist.ac.jp gitlab_gitlab-ce-source/signature | 836 B 00:00:00 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey から鍵を取得中です。 Importing GPG key 0xE15E78F4: Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>" Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4 From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg から鍵を取得中です。 gitlab_gitlab-ce-source/signature | 951 B 00:00:00 !!! gitlab_gitlab-ce-source/primary | 175 B 00:00:01 パッケージ pygpgme-0.3-9.el7.x86_64 はインストール済みか最新バージョンです 何もしません Installing yum-utils... 読み込んだプラグイン:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * epel: mirrors.aliyun.com * extras: ftp.jaist.ac.jp * ius: mirrors.kernel.org * updates: ftp.jaist.ac.jp パッケージ yum-utils-1.1.31-46.el7_5.noarch はインストール済みか最新バージョンです 何もしません Generating yum cache for gitlab_gitlab-ce... Importing GPG key 0xE15E78F4: Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>" Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4 From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey The repository is setup! You can now install packages. [nari@linux4ruby ~]$ [nari@linux4ruby ~]$ sudo yum install gitlab-ce 読み込んだプラグイン:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * epel: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * ius: mirrors.kernel.org * updates: ftp.jaist.ac.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ gitlab-ce.x86_64 0:11.4.4-ce.0.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================================================================== Package アーキテクチャー バージョン リポジトリー 容量 ================================================================================================================================== インストール中: gitlab-ce x86_64 11.4.4-ce.0.el7 gitlab_gitlab-ce 435 M トランザクションの要約 ================================================================================================================================== インストール 1 パッケージ 総ダウンロード容量: 435 M インストール容量: 1.3 G Is this ok [y/d/N]: y Downloading packages: 警告: /var/cache/yum/x86_64/7/gitlab_gitlab-ce/packages/gitlab-ce-11.4.4-ce.0.el7.x86_64.rpm: ヘッダー V4 RSA/SHA1 Signature、鍵 ID f27eab47: NOKEY gitlab-ce-11.4.4-ce.0.el7.x86_64.rpm の公開鍵がインストールされていません gitlab-ce-11.4.4-ce.0.el7.x86_64.rpm | 435 MB 00:00:21 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey から鍵を取得中です。 Importing GPG key 0xE15E78F4: Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>" Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4 From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey 上記の処理を行います。よろしいでしょうか? [y/N]y https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg から鍵を取得中です。 Importing GPG key 0xF27EAB47: Userid : "GitLab, Inc. <support@gitlab.com>" Fingerprint: dbef 8977 4ddb 9eb3 7d9f c3a0 3cfc f9ba f27e ab47 From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg 上記の処理を行います。よろしいでしょうか? [y/N]y Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : gitlab-ce-11.4.4-ce.0.el7.x86_64 1/1 It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md 検証中 : gitlab-ce-11.4.4-ce.0.el7.x86_64 1/1 インストール: gitlab-ce.x86_64 0:11.4.4-ce.0.el7 完了しました! [nari@linux4ruby ~]$ アクセスURLを指定 sudo cat /etc/gitlab/gitlab.rb | grep external_url 1 2 3 4 5 6 7 8 9 [nari@linux4ruby ~]$ sudo cat /etc/gitlab/gitlab.rb | grep external_url ##! For more details on configuring external_url see: #external_url 'http://gitlab.example.com' external_url 'http://192.168.1.87' # registry_external_url 'https://registry.gitlab.example.com' # pages_external_url "http://pages.example.com/" # gitlab_pages['artifacts_server_url'] = nil # Defaults to external_url + '/api/v4' # mattermost_external_url 'http://mattermost.example.com' [nari@linux4ruby ~]$ 初期設定 sudo gitlab-ctl reconfigure 1 2 3 4 5 6 7 8 9 [nari@linux4ruby ~]$ sudo gitlab-ctl reconfigure :(長いので省略) Running handlers: Running handlers complete Chef Client finished, 435/620 resources updated in 02 minutes 20 seconds gitlab Reconfigured! [nari@linux4ruby ~]$ gitのユーザ作成 groupadd gitgroup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 [root@linux4ruby ~]# groupadd gitgroup [root@linux4ruby ~]# useradd -g gitrgoup gituser useradd: グループ 'gitrgoup' は存在しません [root@linux4ruby ~]# useradd -g gitrgoup gitusergoup gituserroup gituser [root@linux4ruby ~]# [root@linux4ruby ~]# passwd gituser ユーザー gituser のパスワードを変更。 新しいパスワード: よくないパスワード: このパスワードは 8 未満の文字列です。 新しいパスワードを再入力してください: passwd: すべての認証トークンが正しく更新できました。 [root@linux4ruby ~]# cd / [root@linux4ruby /]# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@linux4ruby /]# mkdir /git/-server [root@linux4ruby /]# chown gituser:gitgroup /git-server [root@linux4ruby /]# [root@linux4ruby /]# [root@linux4ruby /]# exit ログアウト [nari@linux4ruby git]$ sudo gituser [sudo] nari のパスワード: sudo: gituser: コマンドが見つかりません [nari@linux4ruby git]$ sudo gituser sudo: gituser: コマンドが見つかりません [nari@linux4ruby git]$ su - gituser パスワード: [gituser@linux4ruby ~]$ pwd /home/gituser [gituser@linux4ruby ~]$ cd /git-server/ [gituser@linux4ruby git-server]$ ls [gituser@linux4ruby git-server]$ mkdir sample1-rep.git [gituser@linux4ruby git-server]$ ls sample1-rep.git [gituser@linux4ruby git-server]$ [gituser@linux4ruby git-server]$ [gituser@linux4ruby git-server]$ ls sample1-rep.git [gituser@linux4ruby git-server]$ cd sample1-rep.git/ [gituser@linux4ruby sample1-rep.git]$ ls [gituser@linux4ruby sample1-rep.git]$ [gituser@linux4ruby sample1-rep.git]$ [gituser@linux4ruby sample1-rep.git]$ git init --bare --shared Initialized empty shared Git repository in /git-server/sample1-rep.git/ [gituser@linux4ruby sample1-rep.git]$ ls -la 合計 16 drwxrwsr-x. 7 gituser gitgroup 119 10月 17 11:02 . drwxr-xr-x. 3 gituser gitgroup 29 10月 17 11:02 .. -rw-rw-r--. 1 gituser gitgroup 23 10月 17 11:02 HEAD drwxrwsr-x. 2 gituser gitgroup 6 10月 17 11:02 branches -rw-rw-r--. 1 gituser gitgroup 126 10月 17 11:02 config -rw-rw-r--. 1 gituser gitgroup 73 10月 17 11:02 description drwxrwsr-x. 2 gituser gitgroup 4096 10月 17 11:02 hooks drwxrwsr-x. 2 gituser gitgroup 21 10月 17 11:02 info drwxrwsr-x. 4 gituser gitgroup 30 10月 17 11:02 objects drwxrwsr-x. 4 gituser gitgroup 31 10月 17 11:02 refs [gituser@linux4ruby sample1-rep.git]$ exit ログアウト [nari@linux4ruby git]$ [nari@linux4ruby git]$

 ⭐️