Git:GitHubへのアップロード方法

公開:2026.05.10(日) 14:48

GitHubへのアップロード方法

JavaScriptの学習(JavaScript #9:電卓に1文字消すボタンを追加する)のソースコードをローカルのGitで管理していたが、これをGitHubへアップロードしてみようと思う。

1. GitHubアカウントの登録
登録済みなのでスキップ

2. 新しいレポジトリの作成
◆ GitHubの自分のDashboardページ右上の [+]ボタンより "New repository" をクリック

◆ Repository nameの入力と 公開設定(Public/Private)を選択し [Create repository] ボタンをクリック

◆ レポジトリを作成するとアップロード方法が表示される
新規の場合は "…or create a new repository on the command line" に書かれたコマンドw実行
既にGitで管理している場合は "…or push an existing repository from the command line" に書かれたコマンドを実行

◆ git push時にエラーが出る場合
"git push -u origin" を実行したところ以下のメッセージが表示された
xxx@xxx:~/docker/node.js/calc-vite$ git push -u origin
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

0 件のコメント:

その他の記事