LoginSignup
0
1

More than 3 years have passed since last update.

gitの簡単な使い方(メモ)

Posted at

はじめに

 git初心者です。
 使いたいときに忘れるので、メモしていこうと思います。

前提

 Gitがすでに入っている。

Gitを触る

なんかよくわからないけど、gitのコミットやらプッシュやらするディレクトリを作る。
※作業スペースとこのディレクトリは分けた方がいいらしい。ミスったら前のやつが上書きされるみたい。

GitHubでリポジトリを作る。
 create repositoryで作れる

mkdir git_space
cd git_space

gitの初期化

git init

ファイルをインデックスに追加する。らしい。

git add helloworld.js

インデックスに追加されたものをローカルレポジトリにコミットする。
※メッセージを入力しないと怒られる。しなくてもいいかもしれないけど、した方がいい。
※ファイル内にアクセストークンみたいなのが含まれる場合は事前に消しておくこと!
筆者はやらかして、修正したけど、履歴がgit上に残って公開されてしまった。

git commit -m "first commit"

リモートリポジトリを指定する。

git remote add origin https: //github.com/※※※

ローカルレポジトリの内容をリモートリポジトリに反映させる。

git push origin master

ファイルの更新

とりあえず以下のコマンドを放つ

git add helloworld.js
git commit -m "fixed"

すると、
何行が修正されたみたいなのが表示される
そして、

git push origin master

ファイルの修正もできた!

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