18
22

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 2015-04-02

Gitコマンド一覧

Git設定

$git config --global オプション:
インストールしたGitに対してコマンドラインから設定を行うコマンド
ex)ユーザー設定・メールアドレス設定

$ git config --global user.name
$ git config --global user.email <mailaddress>

リポジトリの作成・メンテナンス

$git init:リポジトリを作成
$git clone:既存のリポジトリの複製を作る
$git fsck:リポジトリの正当性チェックを行う
$git gc:リポジトリ内の不要なオブジェクトを削除し、最適化を行う

作業ツリー,ブランチを操作管理する

$git status:変更が加えられたファイルを表示
$git diff:ファイルに加えられた変更点をdiff形式で表示
$git add:コミットするファイルを指定
$git commit:変更点をコミット
$git reset:コミットlogを閲覧
$git revert:作業ツリーを指定したコミット時点の状態にまで戻す
$git branch:ブランチ情報の表示,ブランチの作成
$git checkout:ブランチの切り替え
$git show-branch:ブランチの作成/ 変更/マージ履歴を表示
$git merge:ローカルブランチのマージを行う
$git tagコミットにタグをつける
$git stash現在の作業ツリーの状態を一時的に保管
$git rebaseブランチの派生元を変更

他のリポジトリとの連携を行う

$git pull:他のリポジトリの変更点をローカルリポジトリにマージ
$git push:公開リポジトリに自分のリポジトリの内容を送信

新しいレポジトリの作り方の例

mkdir SourceTree_rensyu
cd SourceTree_rensyu
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitlab.com/seeker-of-it-my/SourceTree_rensyu.git
git push -u origin master

既存のGitリポジトリをプッシュの例

cd existing_git_repo
git remote add origin https://gitlab.com/seeker-of-it-my/SourceTree_rensyu.git
git push -u origin master

※git remote add [shortname] [url]```:リモートリポジトリの追加


### 新しいことがわかり次第、随時更新していきます。

18
22
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
18
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?