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 5 years have passed since last update.

Git関係メモ

Last updated at Posted at 2018-09-30

1.利用背景

 共同開発時共有等に利用
  -変更
  -準備
  -共有

2.基本的な利用方法

Command 内容
git init 初期化
git add file01 管理へ加える
git commit -m "コメント" 記録+メモ
git remote add origin URL GitHubなどの保存場所を指定
git push origin master リモートへ保存
git pull origin master リモートからDL

基本順序
(add)→(commit)→(push)→(pull※利用者)
※ファイル更新時でも:対象ファイルadd→commit→pushu

3.把握と選択

Command 内容
git status 変更ファイルの把握
git diff 変更箇所の把握
git log 変更履歴確認
git log 変更箇所履歴確認

(status+diff)→(add)

 [status]
  ※変更実施済AndAdd=緑時
  ※変更実施済ButNotAdd=赤字

4.git関連の設定情報の把握

なぜだか、PCで設定済みの名前(本名)でcommitがなされてしまい。
散々困ったので設定状態を把握する方法を忘備録として記載。

[出力イメージ]
(把握)
 git config --global --list
 --
 user.name="commitされる時の名前"
 user.email="現在設定されているアドレス"
 --

(変更方法)
 git config --global user.name "Githubアカウント"
 git config --global user.email "Github登録アドレス"

5.作業ディレクトリ確認

[出力イメージ]
(確認)
$ git rev-parse --show-toplevel
---
gitファイルで指定されているTopディレクトリ:
 /〜HOGEHOGE〜/Python3-LAB/gitsandbox
---

gitsandbox$ pwd
/〜HOGEHOGE〜/Python3-LAB/gitsandbox

gitsandbox$ ls
README.md       ReviewP8-2      ReviewP8-5      commitcheck2.py tw.py
ReviewP8-1      ReviewP8-3      commitcheck.py  if.py           tweetnew.py
gitsandbox$ 

(追加方法)
gitsandbox$ git add ReviewP8-1/main.py

6やらかし修正

 前回のcommitへ修正戻したい:
  git reset --hard HEAD

 間違えてadd:
  git reset HEAD main.py

 フォルダ構成変更:
  1.git rm -r ReviewP8-1(いらないフォルダ)
  2.git commit -m 'HOGEHOGE'
  3.git push origin master

 コミットしたユーザー一括変更:

git
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='HOGEHOGE'; GIT_AUTHOR_EMAIL='hogehoge@hoge.co.jp'; GIT_COMMITTER_NAME='HOGEHOGE'; GIT_COMMITTER_EMAIL='hogehoge@hoge.co.jp';" HEAD

git push --force --tags origin 'refs/heads/*'

  

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?