Create a clean pull request in Git in a new folder/directory. This tutorial is going to help you in setting up a new project in your laptop and also creating a PR of your work.
In order to start this tutorial we are:
– Assuming that you have git set up in environment variables and installed already.
– Assuming that you’ve not cloned any repository.
Steps to create clean pull request:
- Initialize git in the current directory
git init
- Check whether you already have branches or not
git remote -v
if you see nothing, means you haven’t added master and origin, so continue else skip steps 3 and 4 - To add a remote connection with git
git remote add origin "https or git address of your repo"
without quotes (shown in picture)” - To add a git remote branch named “master”
git remote add add master "same address again"
- Now retrieve any changes on the remote master branch
git fetch origin master
- Bring all changes in your current directory from the remote master branch
git pull origin master
(execute these 6,7 steps so that you have the latest code on your local, this is best practice. Now you are currently on the master branch - Make some changes, for example, create a file by typing this command
touch test_file
- To push these changes to the new branch, create a new branch (important to note that you are already on the master branch, all new branches should be made when the user already checked as master)
git checkout -b new_branch
- Now run
git add --all
- Add a commit message
git commit -m "committing a test_file"
- Now push the changes to the newly created branch
git push origin new_branch
- Now do
git checkout master
If you want to add more branches if not skip this step and continue working innew_branch
- Now go to your bitbucket or github.com login, click “create pull request” you’ll see branch “new_branch” is created on the other side choose “master” give notes, and hit the “create pull request” button
- Done.
That’s it for the day, folks. Check out some other interesting blogs and comment. Comments are the only that can help me improve the blog and the kind of content you are looking for from me.