To put all we have learnt together, let's do a little project. Here are the instructions.
Activity 1 1.Create a folder and name it whatever you want. 2.Run the “Git init” command to initialize the folder as a git repository. 3.Make changes to the folder; you can add whatever file you want. 4.Stage the changes using “git add” command. 5.Commit the changes with git commit. 6.Create a remote repository. 7.Link the local repository and remote repository.
1.Note that when you create the folder you have to open the folder before you do "git bash" as shown below; I am stressing this because a lot of people make this mistake, even experienced developers.
2.Run the git init command
- Commit changes;
- Create a remote repository and name it the folder name.
- To link both repositories. Copy the remote repository’s url. Click on code, and copy the link
Go back to "git bash" and run
Git remote
This will return nothing, because we don't have any remote repository linked yet, to link the repository run the command
Git remote add origin [url]
To paste the url, use the insert key on your keyboard.
Make sure you copy the url, then type git remote, add origin, then press insert key.
- “Git push” to push changes to the remote repository.
- Compare and pull request;
- As shown above, the changes are not reflecting because the branch we pushed to was master not main. Hence, just click on “main “and change it to “master” as shown below;
Copy the link to your repository as shown below;
Congratulations, You have successfully created a local repository, made changes to it, created a remote repository, linked it to the local repository, and pushed your changes to the remote repository. Now you can share your code with friends by just copying the link to the repository. Easy, yeah?. Copy the link to your repo and share it with me. Note that this is not compulsory.