![]() Here’s an explanation of each of the above commands: Remember to git commit and git push as usual, to copy your updates back up to GitHub. You can continue working on the files or adding new files. You’re now in the branch that contains all the updates from your PR. Git fetch origin your-branch-name:your-branch-name In the commands, change your-branch-name to the actual branch name: Run these commands to copy the branch containing your PR to your computer.The commands below assume that you’ve cloned the repository into a directory named git-repositories/awesome-repo: Go to the directory containing the repository on your local computer.In the screenshot below, the branch name is gcpsdk: Find your PR on GitHub and check the name of the branch that contains the PR.Download the PR to your computerįollow these steps to copy the PR from GitHub to your local computer: You should also see the files and directories belonging to the GitHub repository that you cloned. git, indicating that Git is tracking the files in the directory. If you take a look at the files in the directory, you should see some file- and directory names starting with. You’re now in a directory called awesome-repo. If you prefer, you can use SSH cloning instead of HTTPS cloning: mkdir git-repositories The commands create a directory called git-repositories and then use HTTPS cloning to download the files: Run the following commands to clone your forked repository onto your local machine.Open a command window on your local computer.For example, if the repository name is “awesome-repo”, then the fork should be at this URL. Find your fork of the repository on GitHub.To clone your fork of the repository onto your local computer: Note: If you’re working directly on the main repository rather than on your fork of the repository, then you should clone the main repository to your local computer. I’m assuming that you have a fork of the repository, and therefore your next step is to clone your fork of the repository to your local computer, as described below. The reason for creating the fork is that you probably don’t have update rights on the main repository. Usually, you fork the main repository on GitHub before creating a PR. You need a clone of the GitHub repository on the computer you’re currently using, so that Git can track the changes you make in the repository. This would be the case if you’ve previously done some work on this repository and on this computer. If you’ve already cloned the GitHub repository to your local computer, you can skip this section. You’ve pushed your latest changes up from your other machine to GitHub, so that GitHub contains the latest version of the PR.Īll you want to do now is to copy a particular PR down from GitHub so that you can work on it on this computer. ![]() (If you haven’t yet created a PR, you can follow this quick guide to working on GitHub, which I created for the Kubeflow open source doc set that I’m currently working on.) You already have a PR that you’ve been working on, and you want to make a local copy of the PR so that you can update one or more files in that PR. ![]() You’re comfortable using command-line Git.This could be useful, for example, if you find that your PR needs to include changes to more than one file, which is hard to do in the GitHub UI. ![]() I needed to transfer my work from my work computer to my laptop, using GitHub as middleman.Īnother scenario for this technique is when you’ve used the GitHub UI to make some changes, but now you want to swap to command-line usage while in the middle of your PR. Then I wanted to continue working on the PR from my laptop at home. I was working on a pull request (PR) on one computer when I was in the office. It took me a while to figure this out when I first needed it. This is a quick tip about a useful Git technique. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |