github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/docs/sources/project/set-up-git.md (about) 1 page_title: Configure Git for contributing 2 page_description: Describes how to set up your local machine and repository 3 page_keywords: GitHub account, repository, clone, fork, branch, upstream, Git, Go, make, 4 5 # Configure Git for contributing 6 7 Work through this page to configure Git and a repository you'll use throughout 8 the Contributor Guide. The work you do further in the guide, depends on the work 9 you do here. 10 11 ## Fork and clone the Docker code 12 13 Before contributing, you first fork the Docker code repository. A fork copies 14 a repository at a particular point in time. GitHub tracks for you where a fork 15 originates. 16 17 As you make contributions, you change your fork's code. When you are ready, 18 you make a pull request back to the original Docker repository. If you aren't 19 familiar with this workflow, don't worry, this guide walks you through all the 20 steps. 21 22 To fork and clone Docker: 23 24 1. Open a browser and log into GitHub with your account. 25 26 2. Go to the <a href="https://github.com/docker/docker" 27 target="_blank">docker/docker repository</a>. 28 29 3. Click the "Fork" button in the upper right corner of the GitHub interface. 30 31 ![Branch Signature](/project/images/fork_docker.png) 32 33 GitHub forks the repository to your GitHub account. The original 34 `docker/docker` repository becomes a new fork `YOUR_ACCOUNT/docker` under 35 your account. 36 37 4. Copy your fork's clone URL from GitHub. 38 39 GitHub allows you to use HTTPS or SSH protocols for clones. You can use the 40 `git` command line or clients like Subversion to clone a repository. 41 42 ![Copy clone URL](/project/images/copy_url.png) 43 44 This guide assume you are using the HTTPS protocol and the `git` command 45 line. If you are comfortable with SSH and some other tool, feel free to use 46 that instead. You'll need to convert what you see in the guide to what is 47 appropriate to your tool. 48 49 5. Open a terminal window on your local host and change to your home directory. 50 51 $ cd ~ 52 53 In Windows, you'll work in your Boot2Docker window instead of Powershell or 54 a `cmd` window. 55 56 6. Create a `repos` directory. 57 58 $ mkdir repos 59 60 7. Change into your `repos` directory. 61 62 $ cd repos 63 64 5. Clone the fork to your local host into a repository called `docker-fork`. 65 66 $ git clone https://github.com/moxiegirl/docker.git docker-fork 67 68 Naming your local repo `docker-fork` should help make these instructions 69 easier to follow; experienced coders don't typically change the name. 70 71 6. Change directory into your new `docker-fork` directory. 72 73 $ cd docker-fork 74 75 Take a moment to familiarize yourself with the repository's contents. List 76 the contents. 77 78 ## Set your signature and an upstream remote 79 80 When you contribute to Docker, you must certify you agree with the 81 <a href="http://developercertificate.org/" target="_blank">Developer Certificate of Origin</a>. 82 You indicate your agreement by signing your `git` commits like this: 83 84 Signed-off-by: Pat Smith <pat.smith@email.com> 85 86 To create a signature, you configure your username and email address in Git. 87 You can set these globally or locally on just your `docker-fork` repository. 88 You must sign with your real name. We don't accept anonymous contributions or 89 contributions through pseudonyms. 90 91 As you change code in your fork, you'll want to keep it in sync with the changes 92 others make in the `docker/docker` repository. To make syncing easier, you'll 93 also add a _remote_ called `upstream` that points to `docker/docker`. A remote 94 is just another project version hosted on the internet or network. 95 96 To configure your username, email, and add a remote: 97 98 1. Change to the root of your `docker-fork` repository. 99 100 $ cd docker-fork 101 102 2. Set your `user.name` for the repository. 103 104 $ git config --local user.name "FirstName LastName" 105 106 3. Set your `user.email` for the repository. 107 108 $ git config --local user.email "emailname@mycompany.com" 109 110 4. Set your local repo to track changes upstream, on the `docker` repository. 111 112 $ git remote add upstream https://github.com/docker/docker.git 113 114 7. Check the result in your `git` configuration. 115 116 $ git config --local -l 117 core.repositoryformatversion=0 118 core.filemode=true 119 core.bare=false 120 core.logallrefupdates=true 121 remote.origin.url=https://github.com/moxiegirl/docker.git 122 remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* 123 branch.master.remote=origin 124 branch.master.merge=refs/heads/master 125 user.name=Mary Anthony 126 user.email=mary@docker.com 127 remote.upstream.url=https://github.com/docker/docker.git 128 remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/* 129 130 To list just the remotes use: 131 132 $ git remote -v 133 origin https://github.com/moxiegirl/docker.git (fetch) 134 origin https://github.com/moxiegirl/docker.git (push) 135 upstream https://github.com/docker/docker.git (fetch) 136 upstream https://github.com/docker/docker.git (push) 137 138 ## Create and push a branch 139 140 As you change code in your fork, make your changes on a repository branch. 141 The branch name should reflect what you are working on. In this section, you 142 create a branch, make a change, and push it up to your fork. 143 144 This branch is just for testing your config for this guide. The changes are part 145 of a dry run, so the branch name will be dry-run-test. To create and push 146 the branch to your fork on GitHub: 147 148 1. Open a terminal and go to the root of your `docker-fork`. 149 150 $ cd docker-fork 151 152 2. Create a `dry-run-test` branch. 153 154 $ git checkout -b dry-run-test 155 156 This command creates the branch and switches the repository to it. 157 158 3. Verify you are in your new branch. 159 160 $ git branch 161 * dry-run-test 162 master 163 164 The current branch has an * (asterisk) marker. So, these results shows you 165 are on the right branch. 166 167 4. Create a `TEST.md` file in the repository's root. 168 169 $ touch TEST.md 170 171 5. Edit the file and add your email and location. 172 173 ![Add your information](/project/images/contributor-edit.png) 174 175 You can use any text editor you are comfortable with. 176 177 6. Save and close the file. 178 179 7. Check the status of your branch. 180 181 $ git status 182 On branch dry-run-test 183 Untracked files: 184 (use "git add <file>..." to include in what will be committed) 185 186 TEST.md 187 188 nothing added to commit but untracked files present (use "git add" to track) 189 190 You've only changed the one file. It is untracked so far by git. 191 192 8. Add your file. 193 194 $ git add TEST.md 195 196 That is the only _staged_ file. Stage is fancy word for work that Git is 197 tracking. 198 199 9. Sign and commit your change. 200 201 $ git commit -s -m "Making a dry run test." 202 [dry-run-test 6e728fb] Making a dry run test 203 1 file changed, 1 insertion(+) 204 create mode 100644 TEST.md 205 206 Commit messages should have a short summary sentence of no more than 50 207 characters. Optionally, you can also include a more detailed explanation 208 after the summary. Separate the summary from any explanation with an empty 209 line. 210 211 8. Push your changes to GitHub. 212 213 $ git push --set-upstream origin dry-run-test 214 Username for 'https://github.com': moxiegirl 215 Password for 'https://moxiegirl@github.com': 216 217 Git prompts you for your GitHub username and password. Then, the command 218 returns a result. 219 220 Counting objects: 13, done. 221 Compressing objects: 100% (2/2), done. 222 Writing objects: 100% (3/3), 320 bytes | 0 bytes/s, done. 223 Total 3 (delta 1), reused 0 (delta 0) 224 To https://github.com/moxiegirl/docker.git 225 * [new branch] dry-run-test -> dry-run-test 226 Branch dry-run-test set up to track remote branch dry-run-test from origin. 227 228 9. Open your browser to Github. 229 230 10. Navigate to your Docker fork. 231 232 11. Make sure the `dry-run-test` branch exists, that it has your commit, and the 233 commit is signed. 234 235 ![Branch Signature](/project/images/branch-sig.png) 236 237 ## Where to go next 238 239 Congratulations, you have finished configuring both your local host environment 240 and Git for contributing. In the next section you'll [learn how to set up and 241 work in a Docker development container](/project/set-up-dev-env/).