LoginSignup
1
1

More than 5 years have passed since last update.

TerminalでGitにコードを挙げる

Posted at

Terminal コードをgitにあげるときのメモ

1. Repositoryを作成する

まずプロジェクトの中までいく、そして以下のコマンドを実行

$  git init  // git repositoryをローカルで新規作成
$  ls  -la // .git ファイルが追加されてるか確認する。

2. プロジェクトをGitにアップする

$ git add. // 全ての変更コードがStagingkされる。
$ git status // 現在のステータスを確認

3.プッシュする

$ git commit -m “First Commit”
$ git status  // “nothing to commit” って表示されてたら、コミットok.
$ git log  // コミットの履歴を確認

4. コミット前の状態にもどす。

git log でコミット番号を取得して、チェックアウトする

$ git checkout (“f46****51c63ab2***e62b3****e44175eee67e6b5”) //こんなコードをコピペする

5. 他ブランチにチェックアウトする。

$ git branch //他ブランチを確認
$ git checkout master //マスターブランチに戻る
$ git status //どのブランチにいるか確認できる
$ git log // 現在のタイムラインを確認でkりう。

6. 存在しているRepositoryにローカルのコードをプッシュする

$ git remote add origin https://github.com/(yourgithubname)/worksflow.git // repositoryの https address をコピーする
$ git push -u origin master // プッシュ
1
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
1
1