2
1

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

これくらいは知っておかないとまずいGitコマンド

Posted at

1.目的

転職してから初めてGitの存在を知り、超基礎レベルのコマンドは打てるようになりました。

ただ、たまに忘れるので、自分用にまとめておくことが目的。
これくらいはさすがにできないとまずいよね、という観点。

使うのはGitHubと、GitBash。

2.よく使うコマンド

(1)事前準備

(ⅰ)GitのDL

下記はwindows用
https://gitforwindows.org/

(ⅱ)GitHubへの登録

(ⅲ)GitHubへの登録その2

Git Bashから下記コマンドで、GitHubへ登録したusernameとメールアドレスを登録する

$git config --global user.name"××××"
$git config --global user.email"△△△△"

(2)コマンド集

基本的に時系列に沿って書いていきます。

●今いるディレクトリを確認

$ pwd

●ディレクトリの変更

$ cd 変更したい場所

●今いるディレクトリ内にあるファイルを確認

$ ls

隠れファイルといった全てのファイルを確認するには下記。

$ ls -a

●gitファイルをディレクトリ内に作成

$ git init

●add

$ git add ファイル名

ディレクトリ内のすべてのファイルをaddする場合は下記

$ git add .

●commit

$ git commit

※補足※
Git Bashでcommitメッセージを入力する際は、まずiを押して挿入モード
→commitメッセージを書いたら、Escキー→「:wq」→Enterを押すと画面を閉じれる

●(コマンドではない)リポジトリの登録

GitHub上でリポジトリを作っておく

●GitHubへのpush

まずはGitHubで作ったリポジトリをGitBash上で登録する。

$ git remote add origin https://github.com/●●(username)/リポジトリ名

GitHubへpushする

$ git push -u origin master

●接続先のリポジトリを変更する場合

現在の接続先を確認

$ git remote -v

接続先を変更

$ git remote set-url origin ●●●(接続先)

以上。
ぼちぼち追記していきます!

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?