Creating a GitHub repository from a local folder involves a few steps. You’ll need to have Git installed on your computer and be logged into your GitHub account. Here’s a step-by-step guide:
Step 1: Install Git
If you don’t already have Git installed on your computer, you can download and install it from the official website: Git Downloads.
Step 2: Open a Terminal or Command Prompt
You’ll need to use a command-line interface (Terminal on macOS/Linux, Command Prompt on Windows) to execute Git commands.
Step 3: Navigate to Your Local Folder
Use the cd (change directory) command to navigate to the local folder that contains the files you want to include in your GitHub repository. For example:
cd /path/to/your/local/folderReplace /path/to/your/local/folder with the actual path to your local folder.
Step 4: Initialize a Git Repository
To make your local folder a Git repository, use the following command:
git initThis command initializes a new Git repository in your local folder.
Step 5: Add Files to the Staging Area
Use the following command to add your files to the staging area. Replace <file> with the name of the file you want to add, or use a dot . to add all files in the current directory:
git add <file>For example, to add all files:
git add .Step 6: Commit Changes
Commit your changes with a meaningful commit message:
git commit -m "Initial commit"Replace "Initial commit" with a descriptive message that explains the purpose of this commit.
Step 7: Create a New Repository on GitHub
Go to the GitHub website and log in to your account.
Step 8: Create a New Repository
Click the “+” icon in the top right corner of the GitHub homepage and select “New repository.” Fill in the repository name, description, and other settings.
Step 9: Create Repository
Click the “Create repository” button to create the GitHub repository.
Step 10: Link Local Repository to GitHub Repository
Back in your command-line interface, link your local Git repository to the newly created GitHub repository. Replace <username> with your GitHub username and <repository> with the repository name you created in step 8:
git remote add origin git@github.com:<username>/<repository>.gitFor example:
git remote add origin git@github.com:ninniku-it-hub/tw.ninniku.accounting.gitStep 11: Push to GitHub
Finally, push your local repository to GitHub:
git push -u origin masterYou might be prompted to enter your GitHub username and password for authentication.
After completing these steps, your local folder and its contents will be on GitHub as a new repository. You can now manage your project’s source code using Git and GitHub.
English Version
Creating a GitHub repository from a local folder involves a few steps. You’ll need to have Git installed on your computer and be logged into your GitHub account. Here’s a step-by-step guide:
Step 1: Install Git
If you don’t already have Git installed on your computer, you can download and install it from the official website: Git Downloads.
Step 2: Open a Terminal or Command Prompt
You’ll need to use a command-line interface (Terminal on macOS/Linux, Command Prompt on Windows) to execute Git commands.
Step 3: Navigate to Your Local Folder
Use the cd (change directory) command to navigate to the local folder that contains the files you want to include in your GitHub repository. For example:
cd /path/to/your/local/folderReplace /path/to/your/local/folder with the actual path to your local folder.
Step 4: Initialize a Git Repository
To make your local folder a Git repository, use the following command:
git initThis command initializes a new Git repository in your local folder.
Step 5: Add Files to the Staging Area
Use the following command to add your files to the staging area. Replace <file> with the name of the file you want to add, or use a dot . to add all files in the current directory:
git add <file>For example, to add all files:
git add .Step 6: Commit Changes
Commit your changes with a meaningful commit message:
git commit -m "Initial commit"Replace "Initial commit" with a descriptive message that explains the purpose of this commit.
Step 7: Create a New Repository on GitHub
Go to the GitHub website and log in to your account.
Step 8: Create a New Repository
Click the “+” icon in the top right corner of the GitHub homepage and select “New repository.” Fill in the repository name, description, and other settings.
Step 9: Create Repository
Click the “Create repository” button to create the GitHub repository.
Step 10: Link Local Repository to GitHub Repository
Back in your command-line interface, link your local Git repository to the newly created GitHub repository. Replace <username> with your GitHub username and <repository> with the repository name you created in step 8:
git remote add origin git@github.com:<username>/<repository>.gitFor example:
git remote add origin git@github.com:ninniku-it-hub/tw.ninniku.accounting.gitStep 11: Push to GitHub
Finally, push your local repository to GitHub:
git push -u origin masterYou might be prompted to enter your GitHub username and password for authentication.
After completing these steps, your local folder and its contents will be on GitHub as a new repository. You can now manage your project’s source code using Git and GitHub.
日本語版
ローカルフォルダからGitHubリポジトリを作成するには、いくつかの手順が必要です。コンピュータにGitがインストールされており、GitHubアカウントにログインしている必要があります。以下にステップバイステップのガイドを示します:
ステップ1:Gitのインストール
コンピュータにGitがまだインストールされていない場合は、公式サイトからダウンロードしてインストールできます:Git Downloads。
ステップ2:ターミナルまたはコマンドプロンプトを開く
Gitコマンドを実行するために、コマンドラインインターフェース(macOS/LinuxではTerminal、WindowsではCommand Prompt)を使用する必要があります。
ステップ3:ローカルフォルダに移動する
cd(ディレクトリ変更)コマンドを使用して、GitHubリポジトリに含めたいファイルがあるローカルフォルダに移動します。例:
cd /path/to/your/local/folder/path/to/your/local/folderを実際のローカルフォルダのパスに置き換えてください。
ステップ4:Gitリポジトリを初期化する
ローカルフォルダをGitリポジトリにするには、以下のコマンドを使用します:
git initこのコマンドにより、ローカルフォルダに新しいGitリポジトリが初期化されます。
ステップ5:ステージングエリアにファイルを追加する
以下のコマンドを使用して、ファイルをステージングエリアに追加します。<file>を追加したいファイル名に置き換えるか、ドット.を使用して現在のディレクトリのすべてのファイルを追加します:
git add <file>例えば、すべてのファイルを追加するには:
git add .ステップ6:変更をコミットする
意味のあるコミットメッセージで変更をコミットします:
git commit -m "Initial commit""Initial commit"をこのコミットの目的を説明する記述的なメッセージに置き換えてください。
ステップ7:GitHubで新しいリポジトリを作成する
GitHubのウェブサイトにアクセスし、アカウントにログインします。
ステップ8:新しいリポジトリを作成する
GitHubホームページの右上にある「+」アイコンをクリックし、「New repository」を選択します。リポジトリ名、説明、その他の設定を入力します。
ステップ9:リポジトリを作成する
「Create repository」ボタンをクリックして、GitHubリポジトリを作成します。
ステップ10:ローカルリポジトリをGitHubリポジトリにリンクする
コマンドラインインターフェースに戻り、ローカルGitリポジトリを新しく作成したGitHubリポジトリにリンクします。<username>をGitHubのユーザー名に、<repository>をステップ8で作成したリポジトリ名に置き換えてください:
git remote add origin git@github.com:<username>/<repository>.git例:
git remote add origin git@github.com:ninniku-it-hub/tw.ninniku.accounting.gitステップ11:GitHubにプッシュする
最後に、ローカルリポジトリをGitHubにプッシュします:
git push -u origin master認証のためにGitHubのユーザー名とパスワードの入力を求められる場合があります。
これらの手順を完了すると、ローカルフォルダとその内容が新しいリポジトリとしてGitHubに公開されます。GitとGitHubを使用してプロジェクトのソースコードを管理できるようになります。
