Last active
November 18, 2016 01:54
-
-
Save knknkn1162/9f4f73ce03ea3fd290a0d5d590b504ac to your computer and use it in GitHub Desktop.
gitに慣れるためのgit入門 ref: http://qiita.com/knknkn1162/items/dedb97da0c96adceb973
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git initしたディレクトリに移動してください。(.gitフォルダがある場所) | |
# 事前に大きすぎるファイルがありそうなときは、確認(100KB以上の物を抽出) | |
# du : ディレクトリ内のファイル容量を表示する。 (-a:ファイルも。 -k:KB表示) | |
du -ak | gawk '{if ($1 > 100) print $0}' | |
# lsで事前に確認 | |
ls directory-name/file* | |
#directory-nameのfile*をステージングエリアに挙げる | |
git add directory-name/file* | |
#もしくは対話的にaddしていく | |
git add -i directory-name/file* | |
# もしくは、一つ一つのファイルに対して、ステージングエリアに載せるかどうか、選択もできる | |
git add -p | |
#事後確認 (modified と untrackedが表示される) | |
git status | |
# addするごとにgit statusで作業内容を確認すると安心ですね! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#もう一回事後確認 (modified と untrackedが表示される) | |
git status | |
#事後確認したら、commit | |
git commit -m "changed" | |
#commitの事後確認2個前までのcommitを確認 | |
git log --stat -2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#初回は、originがどこのurlを指しているか紐づけを行う。2回目以降は不要 | |
git remote add origin https://github.com/username/repository.git | |
# リモートレポジトリの確認 | |
git remote -v | |
# -uはorigin(ローカルリポジトリ)とmaster(ブランチ)の対応付け | |
# (初回のみで良い。対応付けがすんだら、git pushのみでOK) | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#事後確認 (modified と untrackedが表示される) | |
git status | |
# ステージングエリアに乗せてしまったファイルをステージングエリアから外す。 | |
git reset * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# commitの事後確認2個前までのcommitを確認 | |
git log -2 | |
# コミットメッセージを間違えた時(エディタが開いて、コミットメッセージを直に修正できる) | |
git commit --amend | |
# または、コミットを取り消したい(取り消したいコミットが直前のものでないときに用いる) | |
# 5e1d749はcommit識別番号 | |
git revert 5e1d749 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# リモートレポジトリの確認 | |
git remote -v | |
# リモートレポジトリの変更 | |
git remote set-url origin https://github.com/username/repository.git | |
# リモートレポジトリが変更されたことを確認 | |
git remote -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment