0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

usbメモリをGitのリモートリポジトリとして使う

Posted at

状況

  • 作成しているシステムの管理者用プログラムをバージョン管理したい
  • APIを利用するためGithubヘのpushには.gitignoreが必要
  • APIキーが長くて他環境へのコピーが面倒
  • 開発環境と実行環境が別に存在している
  • 別に他人へ配布する予定はない

環境が2つほどであるならばAPIキー程度は頑張ってコピーしましょう

解説

usbメモリのパスをF:とする.

# usbメモリヘ移動
cd F:

# リモートリポジトリの作成
git init --bare

# バージョン管理したいdirへ移動
cd {dir_path}

# リモートリポジトリの追加
git remote add {repository_name; ex:usb} F:

# 確認
git remote get-url usb
> F:

同じusbメモリであっても環境によってパスは異なることに注意

# pushしたいとき
git push usb {branch_name}

# pullしたいとき
git pull usb {branch_name}

mergeとbranch削除について

GithubではないのでPull requestsを作成できない.
ローカルにてmerge > リモートリポジトリヘpushという手順が必要となる.

ここではdevelopmainへmergeする

# mainへmergeする
git checkout main
git merge develop

# リモートリポジトリヘpushする
git push usb main

また,他環境でもそのbranchで作業を継続したいときには,以下の様にする.

# 作業中のbranchをリモートリポジトリヘpushする
git add {file_path}
git commit
git push usb {branch_name}

# 他環境でpullする
git pull usb {branch_name}

この場合にはmergeしてもリモートリポジトリに作業中のbranchが残ってしまうため削除する.

# merge終了して不要となっていることを確認する必要がある
git push --delete usb {branch_name}

参考

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?