User login

Git

Ignore all Vim temporary files


v ~/.gitignore

*.swp
*.swo


git config --global core.excludesfile ~/.gitignore

Replace local files or directories with repository version

git rm -rf directory-that-annoys-us-locally-but-is-ok-in-repository
git pull
git checkout directory-that-annoys-us-locally-but-is-ok-in-repository

Not pretty or proper but it works.

Creating a patch with Git suitable for submitting to Drupal.org

Take the hash of a 'before' commit and the 'after' commit 'sha' hash and stay relative to the current directory and output a patch:

~/code/dgd7/drupal/sites/all/modules/views$ git diff --relative 5ac40a1 cb64d08 > 817748-views-book-hierarchy-sort-12.patch

If you've merely made the changes but not committed them you can use git diff > patch_name-1234-57.patch or if you've staged but not committed you can use git diff --cached patch_name-1234-57.patch.

Putting a local project maintained in git on a server as a central repository

Note: The agaric git repository is not public, but this approach will work on your own server.

Stefan explained: copy your folders to your home dir on the server, cd to /srv/git and then run git clone --bare folder folder.git

cd ~
scp -r customhome ben@grassrootsconnection.org:~/customhome

On the server:

ben@server:/srv/git/agaric$ git clone --bare ~/customhome customhome.git

Initialized empty Git repository in /srv/git/agaric/customhome.git/

And don't forget!

See your git commit history with files modified

Git log shows you all your commit messages and the revision hash, but often git log would be more useful showing files changed. (You should still try to write commit messages as if the reader will have no context except, at best, the project itself.)

git log --name-only -5

Undo a conflicting change in your working copy that you didn't want anyway

In short, resolve a conflict in favor of the outside repository.

The file can be a

mv offending.file ~/elsewhere
git checkout offending.file

See also for resetting everything: http://agaric.com/note/git-update-and-ignore-local-changes

Git update and ignore local changes

The don't-take-no-for-an-answer way:

git reset --hard

Resolution

Restore locally deleted files with git

In SVN, running svn update will restore any files you have deleted locally where you have not explicitly committed the removal. Not so in git (or at least git-svn) for removed or moved files.

The tip found will restore not just one, but every deleted file. Agaric recommends you check what you're restoring with just git ls-files -d (where -d stands for --delete) first.

git ls-files -d | xargs git checkout --

Resolve a conflict to use local files after a merge goes bad in git pull

benjamin-agaric: looking for a little git help... i've got my repos on the server
I was pulling from it, but when I tried to push i noticed that i must have done it wrong and had the repository url as http
I changed that to the ssh style git. --and i was now connected to the repository two ways
the really weird thing is that when I pushed it said it wasn't up to date (could not fast forward), and when I pulled I got a conflict!!

Syndicate content