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?

More than 1 year has passed since last update.

Git備忘録

Last updated at Posted at 2020-02-25

設定

~/.gitconfig

[user] 
        name = Yasushi SHINOHARA
        email = hogehoge@hoge.com
[core]
        editor = vim

~/.emacs

;;disable the version control with emacs
(setq vc-handled-backends nil)

リモートリポジトリを作る

リモートリポジトリ用に作ったhogehoge.gitに移動して

git init --bare --share

でリモートリポジトリが作られる。
gitで管理したいディレクトリに移動して、git remote add origin /path/for/hogehoge.gitでうまくいく という記事がウェブ上で散見されるが、自分のケースではうまくいかなかった。

git clone /path/for/hogehoge.git ./

で空のリポジトリが設定されて、リモートとの関係もgit remote -vで観れることを確認した。

コマンド

git ls-files #gitで管理しているファイルの一覧を表示

branch 関係

git branch      # ブランチを確認
git branch -a   # リモートも含めてブランチを確認

新しくbranch, branch_nameをつくる

git branch branch_name

branch_nameにbranchを切り替える

git checkout branch_name

branch_nameをremoteにpush

git push -u origin branch_name

merge関係

Merge先(ここではmasterとする)のbranchにgit checkoutして移動してから、から、merge元のbranch(ここではdevelopとする)を指定してmergeする。

git checkout master
git merge develop

git tag

git tag -a vx.y.z # タグのコメントを入力するエディタが立ち上がる
git tag -a vx.y.z  -m 'version x.y.z'
git tag -a vx.y.z -m 'version x.y.z' コミットID #後でコミットにタグをつける場合

コミットのIDを省略することで最新のコミットにタグが付く。

git push origin vx.y.z

リモートにもタグを認識させるには、タグをpushする必要がある。

リモートリポジトリ関係

git remote -v # リモートリポジトリとして指定されているpathを表示する

誤ってステージにのせてしまったファイルを管理対象から外したい

git rm --cached ./hoge/hogehoge.pyc

gitk

gitkのフォントが小さいとき、~/.config/git/gitkset mainfont, set textfont, set uifontの数字を大きくすればよい。

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?