Git
Git Tutorial for Beginners with Examples
Install Git
Add Local Project to Remote Git Repository
How to Clone a Project from a Remote Git Repository
Create a New Branch in Git
Switching Branches in Git
How to Push Code from Local to Remote Repository
Pushing a New Local Branch to a Remote Git Repository
Deleting a Git Branch Both Locally and Remotely
Restoring a Deleted Git Branch
Switching to a Different Branch Without Committing Changes in Local Git Repository
Git Stash Revert: How to Restore Stashed Changes in Git
Creating a Git Pull Request
Cancel a Git Pull Request
Tags in Git
Git Commands for Beginners
Generating a Personal Access Token on GitHub
Update the Local Branch with the Latest Code Changes from the Remote Branch
Compare Two different Git Branches in Visual Studio Code
Add Local Project to Remote Git Repository
- Last updated Apr 25, 2024
Follow these steps to add an existing project to a remote Git repository:
- Open your Git Bash or command prompt or terminal on your computer.
- Navigate to the local directory where the project you wish to add to the remote repository is located:
- Run the following command to initialize the local project as a Git repository:
- Add all the files of the project to the staging area:
- Commit the changes to the local repository with a meaningful message:
- Create a remote repository on a Git hosting service such as GitHub, Bitbucket, or GitLab.
- Copy the URL of the remote repository.
- Link the local repository to the remote one by executing the following command:
- Push the local project to the remote repository
cd my-project
git init
git add .
git commit -m 'initial commit'
Replace "initial commit" with your own message.
git remote add origin remote_repository_url
Replace remote_repository_url with the URL of the remote repository you copied in step 7.
git push origin master
This command will push the files of your local project to the remote repository.
Now that your existing project has been added to the remote Git repository, you can work together with others and easily manage the code using version control.