![]() ![]() Instead, I can use the magic of git and GitHub’s pull requests. Now, I could just email him the new files and the instructions of what to change, but that method is time-consuming and error-prone. Because his website is a forked version of mine, the new CSS I made should work perfectly on his site if it were implemented. One would only think so, huh?Īnyway, I just made a post that required me to add new CSS to the site, and if it was to be displayed on Andrew’s GitHub Pages blog correctly, I needed a way to get him that code. One would almost think that this “shared” blog is just my brother Andrew mooching off my work to make quality content, given that he has yet to make a single post. I’ve run into this type of problem a bunch times, so I’m making a really short post on how to make a pull request to a project for just a few specific commits. Have you ever wanted to make a small pull request to improve an open-source project that you have a heavily modified version of? For example, say you have a personal version of a repo that you’ve changed a bunch with a particular aspect you think the main project would find useful, but you don’t want to make them pull all your custom code? ![]() The command is actually short for Create a branch and checkout that branch.Sharing Git Commits with Your Friends Made Easy. In our case, it was to bring a commit from master branch to Feature2019 branch. A common use case of cherry-pick is to forward or back-port a commit from a development branch to say a release branch. The idea of cherry-pick is to choose a commit from one branch and apply to other branch. You can do a git fetch at any time to update your remote-tracking branches under refs/remotes//. Git pull does a git fetch followed by a git merge.Ī git pull is what you would do to bring a local branch up-to date with its remote version, while also updating your other remote tracking branches. What is git pull and git fetch?įound this SO article which clearly explains both the git commands ![]() This tracks all the remote branches in your repository. The best part is that, cherry-picking saves you a lot of time. You will have to specify Feature2019 as the branch that you want your new commits to merge to.īranching out from the branch that you want to merge to was the most important step I had to spend time figuring out. Now, go to your repository link on GitHub and open a pull request. git push origin cp-issue This will push the commit to GitHub.git cherry-pick 6b4g55s6f45s6d5f4g56 we cherry-pick the commit id which we want to merge to the new branch.You need to be checked in to the Feature2019 branch before you branch out to a new branch. git checkout -b cp-issue where cp-issue is the branch created from Feature2019.git pull to make sure you have latest code.git checkout Feature2019 checkout the branch that you want to cherry-pick your changes to.git fetch so that you have latest branch details on your local.git branch -r this will help find if you are able to fetch the newly created branch.However, due to the compulsion of always creating a pull-request, we need to take care certain steps. The best and obvious choice is using the git’s cherry-pick command. We also then need to move our code changes in the Feature2019 branch. ![]() To be able to merge our fixes to both the branches, we use the below workflowįirst, we fix the issue in our master branch, because that is where all the latest code should reside. This means that we need to merge our code fixes to both the master and Feature2019 branch. Sometimes, there can be a situation where we may need to fix a critical defect post our branch cut. git push origin feature/blogpost helps push the commits to the GitHub repository which we than create a pull requestĪfter all the testing is done and during the time of release to customers, we create a new branch out of master branch, let’s call it Feature2019.git pull -rebase origin master Rebase with master before we commit.git commit -m "blog posts ftw committing the changes.git add filname.js adds the file to be committed.git checkout -b feature/blogpost creates a branch extending the master branch.git pull origin master gets me the latest code from master (checked out master branch : because we do all dev work on master).Our git workflow looks something like this The obvious reason being, so that we are forced to get our commits reviewed. Our GitHub settings are such that, we always need to create a Pull Request to be able to merge a commit. Recently I encountered a scenario that taught me how robust GitHub is and so, this post. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |