User:Aude/Git

Checkout
Checkout version from a specific date or point in time:

or

Config
Set global configuration, if only or primarily doing Wikimedia development:

It is important for the email to match your email set in Gerrit, and the name is less important.

Set configuration for individual git repositories:

View global config:

View local config:

If git or gerrit complain about the committer not matching, check the config, and you can also check how your commits are credited:

To commit stuff
This will bring up your text editor where you can enter a commit summary.

You can configure which text editor to use with the export command or add it to your ~/.bash_profile file.

Using the text editor to provide more detailed commit summary is better, however it is also possible to provide the commit summary as an argument in the commit command:

Update local code
in the morning, do:

Submit code for review
Sanity check, make sure you are on the correct branch, etc.

See what you are about to submit:

Instead of git push origin, use git review to submit your change to gerrit:

Branching
Make a local branch:

Create a branch based on a commit hash:

Checkout a remote branch into a local branch:

Make some changes, commit them and push to review.

Create a new remote branch
If needed, gerrit remote needs to be added:

List branches
List remote branches:

List all branches:

See current remote branches:

Get details for a remote:

Deleting branches
To batch delete (wildcard) branches:

or to force delete branches with "not fully merged" stuff:

To delete remote branches, such as on github, where one might have permission to do so:

To batch delete remote branches:

Remove untracked files / clean
Removes directories and files:

Bash prompt
Display the git branch in the bash prompt, the following can be added to your ~/.bashrc file. To make the change take effect, then

When were the branches last modified?
See a list of all branches sorted by last modified date:

Works on windows, mac or linux, but not as pretty:

Tags

 * note, it might be "origin" instead of gerrit.
 * if the remote is not recognized, then it needs to be added per User:Aude/Git

Removing files from a repo
To recursively remove a folder and files from a repo:

Reset
or

View log
Just a plain git log, with details:

Create a patch
From the master branch:

make a bunch of changes

Revert
Revert a specific commit:

Amend specific commit in series of patches
In interactive mode, then:

Then make changes, and then:

Squash a commit
In interactive mode, then:

Edit the commit message, then save and then git will combine the two commits into a single commit.

If amending and resubmitting to gerrit, then.

Merge conflicts
or set it:

Merge in subsequent commits into a patch
When you have resolved this problem run "git rebase --continue".

Submodules
Checkout wmf core branch and extension submodules:

If renaming the core directory, references to the submodules need to be updated.

In core/extensions:

in core/.git:


 * Removing submodules
 * http://davidwalsh.name/git-remove-submodule


 * See also
 * wikitech:How to deploy code

Split subpath
To split subdirectories of a git repo into separate repos:

Create clone copies and then in the clone:

Get a list of projects
In the shell:

Or go to https://gerrit.wikimedia.org/r/#/admin/projects/

Improving a patch
make some changes

Adding a dependency
If you need to amend your patch to have the correct dependency:


 * 1) Resolve conflicts if needed,
 * 2) - use "git status" to see the files that need resolution
 * 3) - after fixing it in your editor, "git add filename" for each of the fixed files


 * 1) * (HEAD, bug/1234) your change
 * 2) * (review/john/700) the dependency
 * 3) * (gerrit/master)

The git push directly will make sure that the dependency is kept and the other revisions that are already in gerrit will not be re-submitted.

Fix a dependency
Change a commit to a new patchset, such as 5a05e0e (5a05e0ef437278eff23c5a8b076b91f0cc7541c8) to cbcd5a0 (cbcd5a08c895d038a3ca7dc10e8d94806e2cae10).

Re-commit your patch replacing the one with the wrong parent

Resubmit to gerrit:

Import github repo into existing empty gerrit repo

 * https://www.assembla.com/spaces/breakoutdocs/wiki/MigrateGitToGerrit

Keyboard shortcuts
Gerrit has keyboard shortcuts. A list of shortcuts can be displayed by clicking "?".

Deployment stuff

 * Each deployment, if extensions not at master:
 * https://gerrit.wikimedia.org/r/#/c/37301/ -- mediawiki/tools/release, make-wmf-branch/default.conf (update commit points, if not master)


 * For new extensions
 * https://gerrit.wikimedia.org/r/#/c/37047/ (new extension)
 * https://gerrit.wikimedia.org/r/#/c/37046/ (for new extension)