03. Como crear un pull request(PR) en Github
How to Manage Branches and Avoid Repository Clutter
Creating a New Branch
- Before starting, it's crucial to note that not all changes can be pushed directly to the Main branch. A new branch will be created using the command
git checkout -bfollowed by the branch name.
- For this new requirement, we will configure the
package.json, adding the prefix "fit" to it. This step successfully creates a new branch.
Managing Node Modules
- It's important not to upload the entire
node_modulesfolder as it would clutter the repository and consume excessive space.
- To address this issue, a new file named
.gitignorewill be created, includingnode_modules/. This action reduces the change count from 4000 to 4.
Committing Changes
- After resolving issues with ignored files, open a new terminal and run commands:
git add ., followed by a commit message like "fit package.json".
- Once committed, you can immediately push your changes. Upon successful push, you’ll see all available branches.
Merging Changes into Main
- The typical next step is to create a pull request (PR) for merging changes back into Main. Click on "New Pull Request" after rendering the screen.
- Add comments in your PR and assign reviewers if necessary. If no reviewers are needed, simply assign yourself within labels before creating the pull request.
Finalizing Changes
- After creating the pull request, you can proceed with merging it into Main. It’s essential to avoid cluttering your repository; therefore, delete any unnecessary branches post-merging.