How To Upload Existing Repository to GitHub
- The system should have git installed in it if not install git. Make sure to choose Run git from Windows Command prompt option during installation. Otherwise, open git bash in place of step 2.
- Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
- Change the current working directory to your local project
- Initialize the local directory as a git repository in different ways as described in the image.
git init
- A new .git folder is created in the directory which is by default hidden.
- Add the files in your new local repository. This stages them for the first commit.
git add .
#Adds the files in the local repository and stages them for commit. To unstage a file, use
git reset HEAD YOUR_FILE
Commit the files that you’ve staged in your local repository.
git commit -m 'First commit'
# Commits the tracked changes and prepares them to be pushed to a remote repository.
To remove this commit and modify the file, use
git reset --soft HEAD~1
And commit and add the file again.
At the top of the GitHub repository’s Quick Setup page, click on the icon shown and copy the remote repository URL.
In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
git remote add origin remote repository URL
# Connects to the remote repository
git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.
git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin.
And here you go…
You may download changes from remote repository to local repository using the command:
git pull
Introduction to Github
Nowadays software development takes place in a distributive way. This article focuses on one such technology that supports distributed software development i.e., GIT and it’s application via GitHub.