LoginSignup
0
0

自分用 業務でよく使うGitコマンド

Last updated at Posted at 2021-02-07

はじめに

自分用なので時々更新されます。

新しいブランチを作成

$ git checkout -b (ブランチ名) origin/master
マスターをもとにブランチの作成

$ git push -u origin (ブランチ名)
リモートにブランチを登録

$ git branch --set-upstream-to=origin/(ブランチ名)
既に登録されているブランチを追跡ブランチに設定

tagの作り方

$ git tag タグ名
コメント(注釈)なしでtagを切る。

$ git push origin タグ名
※tagを作成しただけではリモートに反映されないので必ずpushする。

$ git co -b tag-タグ名 refs/tags/タグ名
タグへの切り替え

tagを削除する

$ git tag -d TAGNAME
ローカルのタグを削除

$ git push origin :TAGNAME

又は

git push --delete origin TAGNAME
削除したものをPUSHする

add から push まで

$ git add ファイル名
ファイル名をステージング環境へaddする

$ git commit
エディターが開き保存するとコミットされる

$ git push origin HEAD
ローカルのカレントブランチがリモートの同名のブランチにpushされる。

削除

$ git rm
git管理下のファイルを削除する。

$ git clean -f
Untracked ファイルの削除
※ディレクトリの場合はdオプションを付ける。

$ git add -u
削除されたファイルをaddする。

##取り込み
$ git merge ブランチ名
現在のブランチにブランチ名のブランチがマージされる。

変更を一時退避

$ git stash
一時退避

$ git stash list
保存状態一覧表示

例.git
stash@{0}: ...
stash@{1}: ...
stash@{2}: ...

$ git stash apply stash@{0}
退避したファイルを戻す

その他

.gitconfigの設定

[color]
branch = auto
diff = auto
status = auto
[alias]
st = status
ci = commit -a
br = branch
co = checkout
df = diff
[user]
name = hogehoge
email = hoge@hoge
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