User:Aude/Git

Checkout
git submodule add ssh://aude@gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataRepo.git extensions/WikidataRepo

General workflow
git commit -a (or) git commit -a -m 'blah blah blah'

git stash save 'blah blah'

in the morning, do: git pull --rebase origin master

git review (instead of git push origin)

Branching
git checkout -b myfeature develop

git checkout -b Wikidata origin/Wikidata

make some changes

git checkout develop git merge --no-ff myfeature

merge changes back into develop branch

git branch -d myfeature

delete branch

Reset
git reset --hard HEAD (or)

git checkout -- hello.php

View log
git log --oneline --graph --decorate master origin/master


 * 37df957 (HEAD, origin/master, origin/HEAD, namespaces, master) selenium: adjusted/extended readme and minor fix in rakefile
 * 1d8956d cleanup of rakefile
 * 080de36 made taskname and target OS in rake configurable via commandline
 * 9bab036 (tag: 2012-26-07) Merge "Adding more GenericArrayObject tests"
 * * 41fcff4 Adding more GenericArrayObject tests
 * | 662f01c fix of recent_changes selenium test
 * |  727541a Merge "Added fixmes, some cleanup and added docs"
 * * | 8a87e58 Adde
 * * | 8a87e58 Adde
 * * | 8a87e58 Adde

Create a patch

 * git branch mychanges
 * make a bunch of changes
 * git add *
 * git commit -m 'made changes'
 * git format-patch master
 * git reset --hard HEAD~1
 * git pull --rebase origin master

Fix a commit
git revert HEAD

Amend author name
git commit --amend --author="New Author Name "

Merge conflicts
git mergetool --tool=/path/to/tool

or set it:

git config --global mergetool. .path (FileMerge for Mac, kdiff3 for Linux)

Merge in subsequent commits into a patch
git review -d 16749 git rebase master git add client/include/LangLinkHandler.php git rebase --continue

When you have resolved this problem run "git rebase --continue".

View diffs
git diff HEAD~1 -- Wikibase.php

Submodules

 * Git - for MediaWiki extensions

Improving a patch
git review -d 


 * make some changes *

git add some/dir/file.txt git commit --amend git review -R

Adding a dependency
If you need to amend your patch to have the correct dependency: git branch # Take note of the review/* branch that was created for this, it has an "*" in front of it git checkout bug/1234 # Check out the local topic branch of your change git rebase review/john/7000 # The branch name of the gerrit change we checked out earlier


 * 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

git commit --amend -c HEAD # Re-commit your patch replacing the one with the wrong parent

git log -n5 --decorate --pretty=oneline # Verify that the last 5 entries of the log now start with:
 * 1) * (HEAD, bug/1234) your change
 * 2) * (review/john/700) the dependency
 * 3) * (gerrit/master)

git push gerrit HEAD:refs/for/master # Use this instead of `git review`

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
git rebase -i gerrit/master

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 git commit --amend -c HEAD

Resubmit to gerrit:

git review -R