Not working for you? See <a href="/node/1065850">Troubleshooting Git clone</a>.
<h2>Routinely</h2>
The headings below are not sequential. What you choose to do depends on where you are in your process.
<h3>Checking your repository status</h3>
To see what you will commit by running <code>git commit</code> and what you could commit by running <code>git add</code> before running <code>git commit</code>.
<div class="codeblock">
<code>git status</code><br />
</div>
<h3>Switching to a different branch</h3>
When you clone the repository you have access to all the branches and tags. The first command shows your choices. The second command makes the switch. See <a href="/node/1066342">branching and tagging</a> for details.
<div class="codeblock">
<code>git branch -a</code><br />
<code>git checkout [branchname]</code><br />
</div>
<h3>Committing all changes locally</h3>
After making changes, add and commit them. Do not begin commit messages with the # symbol. See <a href="/node/52287">Commit messages</a> for details.
<div class="codeblock">
<code>git add -A</code><br />
<code>git commit -m "Issue #[issue number] by [comma-separated usernames]: [Short summary of the change]."</code>
</div>
<h3>Pushing your code back to the repository on Drupal.org</h3>
<div class="codeblock">
<code>git push -u origin HEAD</code>
</div>
<h2>Patching</h2>
<p>Contributing changes with patches is being replaced with <a href="/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests">issue forks and merge requests</a>.</p>
<h3>Getting ready to create or apply patches</h3>
If you have not already cloned the repository, follow the directions above for setting up this repository in your local environment. Be sure you are on the branch you wish to patch, then ensure it is up-to-date with the following command:
<div class="codeblock">
<code>git pull origin</code>
</div>
<h3>Creating a patch</h3>
For most improvements, use the following command after making your changes:
For more complex improvements that require adding/removing files, work over the course of multiple days including Git commits, or collaboration with others, see the <a href="/node/1054616">Advanced patch workflow</a>.
<h3>Applying a patch </h3>
Download the patch to your working directory. Apply the patch with the following command:
<div class="codeblock">
<code>git apply -v [patchname.patch]</code><br />
</div>
To avoid accidentally including the patch file in future commits, remove it:
<h3>Setting up this repository in your local environment for the first time</h3>
If you have just created a project or you already have a local repository, skip this step.
@@ -359,66 +254,8 @@ git push origin tag [tag name]</code></div>
<p>Once you’ve pushed the properly-formed tag or branch, see <a href="/node/1068944">Creating a project release</a> for directions to actually create the release node.</p>',$defaults)];
}
if(!$is_maintainer&&$is_sandbox){
$content[]=['#markup'=>t('<h2>One-Time Only</h2>
<h3>Setting up this repository locally for the first time</h3>
Not working for you? See <a href="/node/1065850">Troubleshooting Git clone</a>.
<h2>Routinely</h2>
The headings below are not sequential. What you choose to do depends on where you are in your process.
<h3>Checking your repository status</h3>
To see what you will commit by running <code>git commit</code> and what you could commit by running <code>git add</code> before running <code>git commit</code>.
<div class="codeblock">
<code>git status</code><br />
</div>
<h3>Switching to a different branch</h3>
When you clone the repository you have access to all the branches and tags. The first command shows your choices. The second command makes the switch. See <a href="/node/1066342">branching and tagging</a> for details.
<div class="codeblock">
<code>git branch -a</code><br />
<code>git checkout [branchname]</code><br />
</div>
<h2>Patching</h2>
<p>Contributing changes with patches is being replaced with <a href="/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests">issue forks and merge requests</a>.</p>
<h3>Getting ready to create or apply patches</h3>
If you have not already cloned the repository, follow the directions above for setting up this repository in your local environment. Be sure you are on the branch you wish to patch, then ensure it is up-to-date with the following command:
<div class="codeblock">
<code>git pull origin</code>
</div>
<h3>Creating a patch</h3>
For most improvements, use the following command after making your changes:
For more complex improvements that require adding/removing files, work over the course of multiple days including Git commits, or collaboration with others, see the <a href="/node/1054616">Advanced patch workflow</a>.
<h3>Applying a patch </h3>
Download the patch to your working directory. Apply the patch with the following command:
<div class="codeblock">
<code>git apply -v [patchname.patch]</code><br />
</div>
To avoid accidentally including the patch file in future commits, remove it:
<h3>Setting up this repository for the first time:</h3>
<p>You will be prompted to enter your Drupal.org password after the last step (and any time you make requests from Drupal.org) if you have not uploaded an SSH key or if your SSH key fails. See <a href="/node/1027094">Authenticate with Git on Drupal.org</a> for details.</p>
<h3>A note about your sandbox and function names:</h3>
<p>Contributed modules on Drupal.org typically use their project’s shortname as the prefix to the module’s functions. Sandbox shortnames are numbers, which are not valid function names. If you intend to release your code for Drupal.org someday, choose a prefix that isn’t being used on Drupal.org already. There is, unfortunately, no guarantee it will still be available when you’re ready to release, but you’ll save a step if it is. To check, type https://www.drupal.org/project/[the_name_you_want].</p>
<p>When you’ve completed these steps, <a href="">refresh this page</a> for further direction.</p>
<p><strong>Note:</strong> You have created a local repository. You will not need to complete the One-Time clone on the next page unless you delete your local repository or set up on a different machine. Then, you’ll need to perform the One-time setup, as will co-maintainers.</p>',$defaults)];
<h3>Setting up this repository for the first time</h3>
<p>You will be prompted to enter your Drupal.org password after the
first and last step if you have not uploaded an SSH Key or if your SSH
key fails. See <a href="/node/1027094">Authenticating with Git on
Drupal.org</a> for details.</p>
<p>See <a href="/node/1027094">Git Authentication for Drupal.org Projects</a> for information about setting up SSH keys and other ways to authenticate.</p>
<div class="codeblock">
<code>mkdir @uri</code><br /><br />
<code>cd @uri</code><br /><br />
@@ -523,7 +334,7 @@ Drupal.org</a> for details.</p>
<p><strong>Note:</strong> You have created a local repository. You will not need to complete the One-Time clone on the next page unless you delete your local repository or set up on a different machine. Then, you’ll need to perform the One-time setup, as will co-maintainers.</p>',$defaults)];
<p>No code is available for %title. <a href="/project/issues/@uri?categories=All">File an issue</a> or contact a maintainer if you have questions.</p>',$defaults)];
}
@@ -605,12 +416,7 @@ function project_git_instructions_version_picker_form_submit($form, &$form_state
* @param $project The project name
* @return boolean Weather the current user is privileged