Skip to content

Latest commit

 

History

History
108 lines (45 loc) · 3.7 KB

Projects 1.md

File metadata and controls

108 lines (45 loc) · 3.7 KB

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.

Solution

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.

image

2.Run the git init command

image

  1. Make changes image

  2. Git status image

  3. Stage changes, git add filename or git add . to stage all changes,

image

  1. Commit changes;

image

  1. Create a remote repository and name it the folder name.

image

image

image

  1. To link both repositories. Copy the remote repository’s url. Click on code, and copy the link

image

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.

image

  1. “Git push” to push changes to the remote repository.

git push origin master image

  1. Compare and pull request;

image

  1. 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;

image

Copy the link to your repository as shown below; image

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.