LoginSignup
0

More than 1 year has passed since last update.

posted at

updated at

【Windows】 GitHub Desktop をインストール後にgit commandでpushするまでの手順

GitHub DesktopでGitHubにpushしていたのですが、
コマンドベースでもできた方がいいかなぁと思い、
GitHub Desktopでインストール済みのgitにパスを通して、
gitコマンドで「git push origin ブランチ名」までを行いました。
その時の備忘録です。

gitのインストール場所(GitHub Desktopのみインストール時)

C:\Users\【ユーザ名】\AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\cmd

パスを通していない状態

> git status
'git' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

パスを通す

Windowsスタート>windowsシステムツール>コントロールパネル>システムとセキュリティ>システム>
システムの詳細設定>環境変数>Path>編集>新規
C:\Users\【ユーザ名】\AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\cmd
を登録

参考(パスを通す)

Windows10でTempやPathなどの環境変数を設定する方法

パスを通した状態

> cd 【リポジトリ】
> git status
On branch 【ブランチ名】
Your branch is up to date with 'origin/【ブランチ名】'.

nothing to commit, working tree clean

リポジトリ内で何かを修正保存

> cd 【リポジトリ】
> git status
On branch 【ブランチ名】
Your branch is up to date with 'origin/【ブランチ名】'.

Changes not staged for commit:

> git add .
> git commit -m "git command test"
[main 061726f] git command test
 39 files changed, 1477 insertions(+)
略

ブランチ名確認

> git branch
error: cannot spawn less: No such file or directory
* 【ブランチ名】

> git push origin 【ブランチ名】
fatal: could not read Username for 'https://github.com': No such file or directory

SSH接続設定

> cd C:\Users\【ユーザ名】\.ssh
> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\【ユーザ名】/.ssh/id_rsa): github_id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

> clip < C:\Users\【ユーザ名】\.ssh\github_id_rsa.pub

GitHub>Settings>SSH and GPG keys>New SSH key から登録
clip < C:\Users\【ユーザ名】\.ssh\github_id_rsa.pubでコピーしたものをペースト

C:\Users\【ユーザ名】下にある(なければ作る?←未検証).gitconfigに以下を追加する

~/.gitconfig
[url "github:"]
    InsteadOf = https://github.com/
    InsteadOf = git@github.com:
> cd 【リポジトリ】
> git push origin 【ブランチ名】

成功!!

参考

GitHubにssh接続する初心者さん

GitHubでssh接続する手順~公開鍵・秘密鍵の生成から~

覚えておきたいgitコマンド一覧

$ git status 【覚えた】
$ git log 【覚えた】
$ git add . 【覚えた】
$ git commit -m "コミットメッセージ" 【覚えた】
$ git checkout ブランチ名
$ git checkout -b ブラント名
$ git push origin リモートブランチ名 【覚えた】
$ git stash
$ git stash apply
$ git pull origin リモートブランチ名
$ git rebase ブランチ名

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
What you can do with signing up
0