![]() 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. If the repo you want to make a pull request to is one that you forked your repo from, then we call that repo “upstream” from yours.We use GitHub extensively at work. A “remote” repos is one that is hosted on the internet somewhere, i.e., on GitHub. The first thing you need to do after making the commits you want shared is establishing some way of loading the other project’s current git data-i.e., adding a “remote” repository. In a nutshell, what we’re going to be doing is loading the other project’s repo into a branch of your project, transfering those 5 specific commits you want shared onto that new branch, pushing that to GitHub and then using that branch to make the pull request. Imagine that you have 500 commits in your repo that you don’t want shared and 5 recent commits that you do. Let’s imagine that you are either trying to share some select few changes with a project you forked, or a project that forked you. You should already have a repo working and know how to pull and push, etc. This quick tutorial assumes a basic level of knowledge on how to use git. In this tutorial, I’ll tell you how to do just that. 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? Sharing Git Commits with Your Friends Made Easy.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |