LoginSignup
0
0

More than 3 years have passed since last update.

【私メモ1】GitとGitHub【必須の基本操作らしいのに概念が最高に初心者泣かせなgitを理解する】

Posted at

作業手順

・ターミナルでの作業内容

mkdir newfile(フォルダの名前)
ターミナルで現在いる場所に新しいディレクトリ作成

touch hello.rb(ファイルの名前)
ファイル作成(拡張子に注意)

・VScode(コードエディタ)での作業内容

git init
gitリポジトリを作成する

git add .
インデックスにファイルを登録

add .だと作業中のフォルダに入っている全てのファイルをインデックスに登録
add hello.rb←特定のファイル(この場合だとhello.rb
)だけ登録することもできる!

git commit -m "ここにコメント"
変更内容の保存
自分がした作業内容とかをコメントに残す


・GitHubでの作業内容

*Google等からGitHubを開いて自分のページでnew repositoryから
リモートリポジトリを作成する

*出来たらurlをコピー


・VScode(コートエディタ)に戻って行う作業内容

git remote add origin URL
ローカルリポジトリとリモートリポジトリを関連付ける

originの部分は好きな名前でOK!

git push origin master
ファイルがプッシュされる
origin masterの部分省略可能


・branchの使い方

git branch
自分が今作業してるブランチを確認

git checkout -b new_branch_name
新しいブランチの作成
new_branch_nameのところが新しいブランチの名前になる
名前は_で繋ぐ


コードに変更加えたら
git add → git commit -m "変更内容" → git push
この流れで新しく書き換わる!

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