0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git/github 覚書

Posted at

気になっていてそのままだったgit/githubをやっとこさ触ってみました。
Atomで使うことを前提に色々調べながらやりました。個人的に躓いたところとかをメモ代わりに記載していきます。

後々連携する場合は事前準備として先にgithubにリポジトリを作成しておくこと。

プロジェクトディレクトリを作成、移動。そして

git init

空でコミットしておく。この方がAtomと連携する場合に良さそうです。

git commit --allow-empty -m "First Commit"

先に作成したgithubのリポジトリを登録。
※atomを開く前にリモートリポジトリ登録しておかないと「No Remote」という表示が出てどうにもならなくなる。

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

ローカルとリモートを同期させる意味でfetch。

git fetch

ここまで来たら無事にAtomでgit/githubを扱えるようになったので。

atom .

pushに失敗した時は

% git fetch && git merge origin/master

この時

fatal: refusing to merge unrelated histories

と表示されマージに失敗した時は

% git merge --allow-unrelated-histories origin/master

とすると

Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

というコメントと共にマージすることができる。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?