自分の為のメモです。いろいろと書き足していく予定です。
初めに
Contents
インストール
git download
使い始める
1.5 使い始める – 初期設定
ユーザー名とメールアドレスの設定
git config --global user.name unimoni
git config --global user.email unimonii@test.dummy.com
確認
git config --list
一番下に追加されている。
git の削除(Windows 版)
Linix のコマンドをWindows でやるならこんな感じですかね ^^
rmdir /S /Q .
リポジトリの作成
作業フォルダの初期化(新規作成)
git init
$ git --help
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--config-env=<name>=<envvar>] <command> [<args>]
These are common Git commands used in various situations:
魏t
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
クローンする
git clone https://github.com/*********/gpost.git ./test
サインインを聞かれるので、ブラウザでサインインを選択して、
ユーザーアカウントと、パスワードでサインインする。
ブランチ
ブランチって枝の事で、派生のことだと思ってます。
ブランチ切り替え
既存ブランチの変更
git checkout test1
新規ブランチへの変更
git switch -c root1
ローカルに作成
git branch <branch-name>
ローカルに別のブランチのとしてクローン
git checkout -b [ローカルで作るブランチ名] [リモートリポジトリ名]/[元となるリモートブランチ名]
アップロード
git push -u origin <branch-name>
ブランチの削除
git push origin --delete
ソースの管理
流れとしては、コミット →プッシュ →マージ
https://qiita.com/yukiyoshimura/items/7aa4a8f8db493ab97c2b
管理の対象を追加する。
コミットの対象を追加するという解釈でも。
「.」はフォルダ全体をさす。
git add .
逆の操作(管理の対象から除外する。)は「rm」
ステータス
管理対象の状況を確認する。新規で追加したとか、編集されている、とか
git status
前回のコミットからの変更点を確認する。
git diff
コミット
ローカルにある編集内容を確定する感じ。「-m」でコメントを入れる。
プッシュ(アップロード)する前の準備みたいな。
git commit -m"comment"
プッシュ
git push origin ブランチ名
origin って何?
git push origin
の origin
は、リモートリポジトリのデフォルトの名前です。Gitでは、ローカルリポジトリとリモートリポジトリを使いますが、origin
はリモートリポジトリの場所(URL)を簡単に呼ぶための別名です。
プッシュ前
プッシュ後
変わってる。
不整合とか起きていると、書き込みを拒否(下記のエラー。)されるので、git pull したりして修正します。
その時にコメントを書き込め見たいな画面になるのですが、unix 系のvi エディタになります。(環境設定でメモ帳に出来たりするのかも?)
! [rejected] main -> test2 (non-fast-forward)
error: failed to push some refs to 'https://github.com/*******/gpost.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
参考:vi エディタ
(Visited 21 times, 3 visits today)