Skip to content

Instantly share code, notes, and snippets.

@noboo
Created July 27, 2019 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noboo/976e100b8b22c292fdbd4bfbcb66db64 to your computer and use it in GitHub Desktop.
Save noboo/976e100b8b22c292fdbd4bfbcb66db64 to your computer and use it in GitHub Desktop.
github - git

github - git

セットアップ

…or create a new repository on the command line

echo "# repository" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/noboo/repository.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin https://github.com/noboo/repository.git
git push -u origin master

status:ローカルレポジトリの状態を確認する

git status

clone(github上のレポジトリをローカルに持ってくる)

git clone -b ブランチ名 https://リポジトリのアドレス

add (編集したファイルを追加)

git add ファイル名
git add --all //ファイルすべて
git add . // 現在のディレクトリのファイルすべて
git add *.js //複数ファイルを一括
git add dir/*.js
git reset //addをリセット

commit (ローカルレポジトリの変更を保存)

git commit -m "メッセージ"
git commit -am "-aオプションを付けるとaddとcommitを一緒にできる"

push (リモートレポジトリに変更を反映する)

git push origin master

pushできない時

ssh-add ~/.ssh/id_rsa

pull:リモートレポジトリの変更内容を取込む

git pull

git push が reject されたときの対処

git pull

とか

git fetch
git merge origin/master

とか

git fetch
git rebase origin/master

bacchi として、このエラーがなかなか直らないとき

git pull origin bacchi

キャッシュ削除の方法(.gitignore反映させる)

$ git rm -r --cached . //ファイル全体キャッシュ削除
$ git rm -r --cached ファイル名  //ファイル指定してキャッシュ削除
git add .
git commit -m "メッセージ"

gistを保存

git submodule add GistURL 名前

.gitignore_global作成

はじめに,ホームディレクトリに.gitignore_globalを作成

touch ~/.gitignore_global

/Users//.gitignore_globalができる

.gitignore_globalに無視したいファイルを追記

.DS_Store

.gitignore_globalを有効化します.ターミナル上で

git config --global core.excludesfile ~/.gitignore_global

と実行するか?直接~/.gitconfigに

[core]
    excludesfile = /Users/<username>/.gitignore_global

と追記。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment