0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

github使ってみたので備忘録

Posted at

githubへ入門した

ほかのサイトにもあるので省略するが、まずgithubのサイトに登録し使用できるよう準備。

remoto repogitoryを作成し、一通り実行したことを備忘録。

https://github.com/Kenichiro-bit/edge_cnn.git

まずgit bashにて

$ mkdir github
$ cd github/
$ mkdir pushtest
$ cd pushtest/
$ git init
Initialized empty Git repository in C:/Users/takig/github/pushtest/.git/

git init でローカルリポジトリを作成した

$ touch test.txt
$ git add test.txt

git add でローカルの中のキャッシュ?に保存

$ git commit -m test.txt

これでコミット完了。-mはメッセージを残すことらしい。

$ git log

で変更履歴を取得。

$ git remote add origin https://github.com/Kenichiro-bit/edge_cnn.git
$ git push origin master

これで、githubのリモートリポジトリの中にpush成功。しかし、mainには反映されていない??
image.png
masterというブランチで登録されてしまった。。。これでは、きちんとpushできない。。。

なので、mainのブランチを作ってそれをpushする形で対応。

$ git merge --allow-unrelated-histories origin/main
$ git push origin main

これで、mainにpushすることができた。

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 379 bytes | 189.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: Create a pull request for 'testd' on GitHub by visiting:
remote:      https://github.com/Kenichiro-bit/edge_cnn/pull/new/testd
remote:
To https://github.com/Kenichiro-bit/edge_cnn.git
 * [new branch]      testd -> testd

こんな感じ。

試しに、dirも作ってそれをpushしてみる。

$ git branch testd
$ git checkout testd

$ mkdir test1
$ cd test1/
$ touch gogo.txt
$ cd ../
$ git add test1/

$ git status
On branch testd
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   test1/gogo.txt

$ git commit -m test1/
$ git push origin testd

image.png

$ git checkout main
$ git merge testd main
$ git push origin main

これで、mainにtestdを追加して、push成功。。。。

初めてのgithubちょっと難しかったけど便利であることは分かった。ここから開発を始めていきたい

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?