How To Make Pull Request: Guide For Beginners

How To Make Pull Request: Guide For Beginners

One of your goals as an upcoming software developer is to reach a level whereby you can collaborate and work with fellow developers on different projects while contributing to the success of the project from the start to the project completion.

When you start working on a team project, you will familiarize yourself with the word PULL REQUEST.

I will therefore be working you through how to make pull requests.

  1. Have Git installed on your system. you can visit %[git-scm.com/downloads] to get it downloaded for both windows and mac. Git gets downloaded with command prompt or terminals called Git Bash and Git GUI.

    I will strongly recommend GIT Bash as it helps you get conversant with git commands and how git works under the hood.

  2. Create a folder for your new project or an existing project you intend to contribute to. Note: Do not initialize git by doing git init in the folder you created as git will already be initialized in the project folder you are cloning from your repository except of course you are the one starting out with the project.

  3. Go to the remote base repository where the original project you are working on is stored, on the top right corner of your screen, you will see a Fork icon click it to fork the repository which automatically creates a copy of the repo in your own personal remote repository. Screenshot (22)_LI.jpg

  4. After Forking, Go back to the folder you created earlier for the project. Right click on your mouse and you will see the two terminals mentioned earlier which will display as:

    Git GUI here and Git Bash here Click on Git Bash here and a terminal will get opened for you. Screenshot (20).png

  5. Return to your remote repository, click on code displayed in green color, you will see clone > https and a url. copy the url and paste it in your terminal during the next step below. Screenshot (24)_LI.jpg

  6. In the terminal, in front of the dollar sign, enter the command git clone <url> press enter and the project will be automatically downloaded in the folder you created.

    Note: If your remote repo is on main branch and your local repo is on master branch, you should rename your local repo to main in other to match with the remote repo by entering the command: git branch -M main Screenshot (25).png

  7. Create a new branch for the project.

    This should be your habit as a developer always to create branches for your projects. Enter the following command to create a new branch: git checkout -b 'new branch name' this command automatically checks you out of the main branch into your new branch.

  8. Make all the necessary changes to the project.

  9. Enter git status to check the present state of the changes you have made.

  10. Enter git add . to add all your files to the staging area.

  11. Enter git status again to confirm the status if all your your files have been added to the staging area.

  12. commit your changes by entering the command git commit -m 'my first commit' hit enter. WOO! you have successfully made your first commit.

    Note: There are two ways to make a pull request. firstly:

  13. Push to your own remote repository first by entering the command git push origin main go to your remote repository, you will see the option

    compare and pull request. click it and at the bottom of the page, you will see Make request click as well and VOILA! you have made your first pull request.

The second step is recommended if you have been added as a contributor to the project. if not, stick to the first step. As a contributor, you have access to pull, push and merge pull request.

  1. Clone directly from the base repository where the original project is kept as described in step 5 instead of your own repository.
  2. Make your changes, Enter the command git add . to add all your changes to the staging area, git status and then commit your project by doing git commit -m 'my new commit'
  3. Enter the command git push origin new-branch. This will automatically push your changes to the base repository where you can now merge. Note: if you are not a contributor, you can only pull from the base repository and not push as your access to the repository will get denied.

IT WORTH THE PATIENCE RIGHT! HAPPY CODING. Contact me if you encounter any challenge.