User login

Git

Downloading zipped tarballs of code from Gitorious

The place to download code for projects on Gitorious (as code, not as a clone of the repository) has proven difficult to find for several people, including myself.

For a project without tags and branches that you just want to download HEAD, the path looks like:

gitorious.org/projectname/repositoryname/archive-tarball/master

To find it, go to your project page and click for either the commit log or the source code tree of a repository, and it will add this link on the side for "Download master as tar.gz"

Committing selected changes in files, not all the changes, with git add -p

For committing just some changes in a file, use

git add -p

y to apply the hunk presented, n for not that hunk, and s to split the hunk smaller – and e to edit manually

It is all explained in the Interactive Mode portion of the git add manpage:

http://www.kernel.org/pub/software/scm/git/docs/git-add.html#_interactive_mode

Completely undo commits and history that should never have been

This fix is being done from a remote repository, because stuff was pushed there that shouldn't have been. However, this repository is only supposed to be cloned and not pushed to (one way one time), so we can destructively set it back to the way it should be.

cd /srv/git/agaric/siteproj.git
git reset add42b74103a4c756d7d55c4abf3d5b0ff914b0c

where that is the last good commit.

And that's it.

File this under do not do this at home.

Pushing our local repository to Gitorious


git checkout master
git remote add origin git@gitorious.org:remarkup/remarkup.git
git push origin master

This was for a module named "remarkup" as covered in http://definitivedrupal.org/node/90

Cloning git locally to test a Drupal module in development on multiple sites

Working on a site (DefinitiveDrupal.org) which is in its own big Git repository. But when working on a module that's custom to the site but probably will become generalized and contributed back, we simply git init in that module's directory to make it a repository too. No git submodules or other voodoo. In addition to getting us an independent commit history for that module, it gives us the ability to throw that module into other situations and work on it there.

See what's about to be committed when using git, and remove something before committing

git diff of files that have been staged ie 'git add'ed
git diff --cached

http://www.commandlinefu.com/commands/view/1242/git-diff-of-files-that-have-been-staged-ie-git-added

$ git commit ...
$ git reset --soft HEAD^ (1)
$ edit (2)

And just commit again.

Undo a git add - remove files staged for a git commit

git reset filename.txt

Will remove a file named filename.txt from the current index, the "about to be committed" area, without changing anything else.

To undo git add . use git reset (no dot).

Git revert a commit

To revert a very simple commit, this is enough:

git revert ba24a3fdeae4a3a034691308171d798d2ddbf93e

Where that long string of characters is the ID of the commit you are reverting.

For a more careful approach to a complex revert, read on...

(if things go horribly wrong we can throw out this branch-- note we may have to commit everything in the branch in order to switch to another branch and delete this one with git branch -D revert-alpha-6

Syndicate content