2022_11_18_linuxでの個人用gitの設定

conda環境の立ち上げ

conda activate mizo_python

gitのインストール

conda install -c bioconda git

git configの設定。ユーザー名、メアドを登録し、改行コードの自動変換をオフにする。pull/pushのデフォルトをfast-forwardにし、fast-forwardできないときには失敗するように設定。(要勉強)

git config --global user.name mizobata.hideaki
git config --global user.email mizobata.hideaki@gmail.com
git config --global core.autocrlf false
git config pull.ff only

github上でリモートリポジトリを作成。今回はlocal blast server用のリモートリポジトリを作成。

ブラウザ版githubにログイン→右上のアイコン→Repositories→Newから作成。今回のリポジトリ名はLocal_blast_server

アクセストークンを作成。これはgit pushするときにパスワード代わりに必要となる。

ブラウザ版github→settings→developer settings→personal access tokens→Tokens(classic)→generate new token→repoにチェック

今回作ったtokenは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

ローカルブラストサーバーのディレクトリに移動。(m768.sにて)

cd /home/mizobata.hideaki/local_blast_server

gitの初期化。現在のディレクトリをgit管理下に置く。

git init

リモートリポジトリとローカルリポジトリの紐付け。github上のリモートリポジトリlocal_blast_serveroriginとして登録。

git remote add origin https://github.com/hmizobata/local_blast_server.git

ディレクトリ内のファイルをすべてステージング

git add -A

ブランチの作成

git branch -M main

更新(今回はなにもないところにスクリプトを追加)をコミット(-mオプションでメモを残せる)

git commit -m "first commit"

pushする前にリモート(origin)からローカル(main)にpullして同期する。

git pull origin main

エラーが出た場合、fast-forwardができないような更新の構造になっているため、臨機応変に対応する。今回は–rebaseで対応。このサイトがわかりやすい?

ユーザー名とパスワードを求められるので、hmizobata,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を入力。

git pull origin main --rebase

データをプッシュ。

git push -u origin main
  • 2022_11_18_linuxでの個人用gitの設定.1670563834.txt.gz
  • 最終更新: 2022/12/09 05:30
  • by 133.11.50.163