LoginSignup
1
2

More than 5 years have passed since last update.

Git/GitLabの使い方(忘備録メモ)

Last updated at Posted at 2018-04-25

gitのレポジトリ作成

gitlabからレポジトリを取得。

$ git clone レポジトリ名

公開鍵の作成・登録

1. キーペア(公開鍵と秘密鍵)を作成

$ ssh-keygen -t rsa

(~/.ssh以下にid_rsa(秘密鍵)、id_rsa.pub(公開鍵)の2ファイルが作成される。)

2. gitlabの'SSH Keys'へ移動
<鍵の名前>.pubの方をコピペする
SSH Keyが作成される。

gitの使いかた

Branchの作成

$ git branch ブランチ名

書いたコードをpushするまで

1 コードをadd

$ git add -A
# もしくは
$ git add .

2 コードをcommit

$ git commit -m 'コメント'

3 コードをpush

$ git push -u origin ブランチ名

pullしたいとき

1 pullしてきたいbranchに切り替える

$ git checkout ブランチ名

2 fetchでコードを取ってくる

$ git fetch --prune

3 pullでコードを統合する

$ git pull 

特定のコミットまで戻す

$ git log

履歴を確認し、戻りたいコミットのハッシュをコピペ

$ git reset --hard

戻す

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