How to synchronize your local repository with GitHub
To synchronize your local repository with GitHub, proceed as follows:
- Go to the GitHub official website and make sure you are logged in
- In the top right corner, you should find a + sign. Click this and then click New repository
- Enter the name of your repository (GitProject)
- Add a description of your repository — something like “My first git project”
- Click the button to create the repository.
These steps have created an empty repository on GitHub; you now need to synchronize your local repository with GitHub.
Replace USERNAME with your GitHub username in the following.
git remote add origin git@github.com:USERNAME/GitProject.git
git push -u origin master
N/B: If you make a mistake in this command (such as not using the correct username or repository name), you can delete the remote repository and start again with the command below.
git remote remove origin
From now on, after you make and commit changes, all you need to do is git push(without the -u origin master) to ‘push’ your changes onto GitHub.
This means you can continue your work from anywhere if you have access to a computer with Git and your application software installed on it.
Now let’s enter the second phase, where we would like to resume our work from a remote machine.
- Clone the repository from the server.
- git clone “repository link”.
- cd into the cloned repository.
- Make your changes to the files needed.
- Add/stage the modifications made in files, commit, and push.
- git add *
- git commit –m ‘Your commit message’
- git pull
- git push
woohoo!!!!!!, our changes are now on GitHub and we can access them remotely.
Adding multiple people to the same repository
One of the best ways for building software is by collaboration(ie working as a team). This is one of the recommended skills in the software development industries. Don’t worry I will make you good at this as you follow on.
Inviting users to your Github repository
Inviting your friend to access your Project so that he can assist you to implement some functionalities is easy with the steps as follows:
- Ask for the username of the person you’re inviting as a collaborator. If they don’t have a username yet, they can sign up for GitHub.
- On GitHub, navigate to the main page of the repository.
- Under your repository name, click Settings.
4. In the left sidebar, click Collaborators.
5. Under “Collaborators”, start typing the collaborator’s username.
6. Synchronize our local repository with GitHub and we can work remotely on different machines as long as these machines have git running.
7. Invite friends to join us in building our projects.
Conclusion
At the end of this module, we have been able to
- Synchronize our local repository with GitHub and we can work remotely on different machines as long as these machines have git running.
- Invite friends to join us in building our projects.