You can watch the youtube video explaining this topic here.
Introduction
A pull request is a way for you to contribute to a project by making changes to the code of a project, and then asking the repository owner to merge your changes with the current main project.
We've done a blogpost on pull requests for github, so in this post we'll look at pull requests bitbucket. There's a different etiquette for bitbucket pull requests compared to github, so we'll need to use a different way of making the pull requests. The two ways that we can raise a pull request on bitbucket are (1) by forking the repository, or (2) by making a new branch. The Fork Way
On the bitbucket website, you can fork a repository (making a copy of your own), make your changes to your personal version of the repository, and then go back to the original repository and raise the pull request, offering your version of the code to the original repository.
This is very good for open source projects, which github is famous for, but isn't as good for bitbucket. Nevertheless, the process is:
This method works, but has a lot of drawbacks. The next way to make a Pull Request is the preferred method.
The Branch Way (Preferred)
If your project is on bitbucket, then you're likely working on a small-ish team with other people. This means that you have more freedom to edit the actual project, and so forking is unnecessary. (Your boss probably doesn't want random forks of the project all over the place. And even if your code doesn't get merged immediately, it should be part of the main project for other people to see.) For this reason, creating a branch on the project repository and making the pull request from that branch is best practice.
The process for making a pull request via making a new branch is:
1. Clone the bitbucket repository you want to contribute too.
git clone repolinkhere
2. (Make sure you're on the right branch and in the project directory, on your local computer.)
git checkout thebranchnamehere
3. Make the changes to the project, on your local computer.
4. Add and commit the changes on your computer. (Make as many commits as you want.) git add . git commit -m "Added feature XYZ."
5. Create a new branch for your changes, on your computer.
git checkout -b yourbranchname
Note: Make your branch name descriptive. For example, naming it "feature/XYZ" if it's a new feature and is about XYZ is easy to let anyone know what the branch is for.
7. Push your changes to the bitbucket repository.
git push --set-upstream origin yourbranchname
8. In the repository in bitbucket, go to the 'Pull requests' tab, and click "Create pull request".
And your PR is created. Using branches is pretty simple, and much cleaner than forking. All professional teams should be handling their pull requests this way.
Conclusion
Pull Requests on bitbucket are pretty easy. Make sure you use the branching technique when possible, though, as it becomes very relevant when wanting to edit your Pull Request.
In the next blogpost, we'll look at how to make changes to the code in your Pull Request after making it.
Like this content and want more? Feel free to look around and find another blog post that interests you. You can also contact me through one of the various social media channels.
Twitter: @srcmake Discord: srcmake#3644 Youtube: srcmake Twitch: www.twitch.tv/srcmake Github: srcmake Comments are closed.
|
AuthorHi, I'm srcmake. I play video games and develop software. Pro-tip: Click the "DIRECTORY" button in the menu to find a list of blog posts.
License: All code and instructions are provided under the MIT License.
|