LoginSignup
1
1

More than 5 years have passed since last update.

Gitlabとpythonでの開発

Last updated at Posted at 2019-03-19

※Git初心者の備忘録なので悪しからず。

初めてファイルをあげる

.gitigonoreの設置は以下を参照
・あとからまとめて.gitignoreする方法
https://qiita.com/yuuAn/items/b1d1df2e810fd6b92574
・github/gitigonre
https://github.com/github/gitignore/blob/master/Python.gitignore

#gitの準備
$ cd existing_folder
$ git init                                           //gitリポジトリの作成
$ git remote add origin <GitURL>                     //リモートリポジトリの指定

#git ignore の設置
$ vim .gitignore
#vimが開くので、iキーを押してインサートモードにしたのち、
https://github.com/github/gitignore/blob/master/Python.gitignore
をコピーして貼り付け
escキーを押してモードを切り替え
:wq!キーで保存


#initial commit
$ git add .                                          //変更対象のファイル等を指定する
$ git commit -m "Initial commit"                           //変更状態の保存
$ git push -u origin master                          //リポジトリアップロード

#.gitignoreの設置


ブランチの作成

$ git checkout -b 作成するブランチ名

編集していくとき

・まず、全ブランチを引っ張ってくる
※参考
全ブランチをリモートリポジトリからpullする
https://qiita.com/muraikenta/items/e590a380191971f9c4c3

$ for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done
$ git fetch --all
$ git pull --all

・編集したいブランチに移動し、devブランチの状態に合わせる。

$ git checkout 作業ブランチ名
$ git merge dev

・内容に何らかの変更を加える

#任意の編集作業

・変更内容をローカルに保存

#add -Aは変更を全部記録する
$ git add -A
$ git commit -m commitの名前

・変更内容をリモートに保存

$ git push origin 作業ブランチ名 

・変更内容をdevブランチにも適用する

#被適用ブランチに移動
$ git checkout dev
$ git merge 適用ブランチ

#リモートに適用
$ git push origin dev

・devの変更内容をmasterブランチにもマージする(なるべく開発責任者only)

#devブランチをAWS環境用に編集したうえで
$ git checkout master
$ git merge dev
$ git push origin master

mergeがconflictしたとき

#略
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