To migrate a local Git repository to GitHub, follow these steps:
- Create a new repository on GitHub:
Log in to your GitHub account.
Click on the "+" icon in the top right corner and select "New repository".
Give your repository a name and an optional description, and choose its visibility (public or private).
Optionally, select additional options like initializing the repository with a README file or adding a .gitignore file.
Click "Create repository".
- Go to your local Git repository directory in the command line or terminal.
- Add your GitHub repository as a remote:
Type the following command: git remote add origin
- Push the local repository to GitHub:
Run the command: git push -u origin master
This pushes your local repository's master branch to the master branch of the remote repository (GitHub).
If you have a different branch you want to push, replace master with the branch name.
- Enter your GitHub username and password (or personal access token) if prompted.
- Once the push completes, go to your GitHub repository page and refresh it. You should see your code and files from the local repository now on GitHub.
Your local Git repository is now successfully migrated to GitHub.