Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, September 22, 2011

Ignoring changes in a tracked file in git

Ignore changes:

git update-index --assume-unchanged 

Un-ignore changes:
git update-index --no-assume-unchanged



[source]

Monday, August 8, 2011

Setting 'git pull' to use --rebase for all branches

git config --global branch.autosetuprebase always

Wednesday, February 9, 2011

Tuesday, December 7, 2010

Some command line utils for git conflict resolution

Git has some nice utilities that can make dealing with conflicts much easier.

If after merging you just want to keep either the remote (theirs) or your own file (ours), you can checkout the file with either --ours or --theirs options as in:
git checkout --ours index.html
git checkout --theirs template.html

In order to look at the original files, git show :1:filename shows the common ancestor, git show :2:filename shows the HEAD version, and git show :3:filename shows the MERGE_HEAD version.



Sources:
Keep either file in a merge conflict

Monday, November 1, 2010

Ignore changes to a file in Git

Temporarily ignore changes to a file in git:
git update-index --assume-unchanged filename
To start tracking changes to the file again, run:
git update-index --no-assume-unchanged filename
source: http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

Revert a file in Git

To revert a file with uncommitted changes to the current version in the repo do:

git checkout -- filename


source: http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file

Friday, September 10, 2010

List just the files that have changed in git.

To show the files that have changed between two revisions:
git diff --name-only foo bar

To show the files that changed for a particular commit:
git show --pretty="format:" --name-only *commit-sha*

Monday, November 30, 2009

github, ssh config file and ssh-agent

Github makes use of ssh-keys for checking out your stuff via git. I also have several different keys and store them with different names such as github_rsa or some such. In order to get this to work, you have to create a config file that stores the location of the private key.

For github, in the .ssh/ directory, create a file `config` and enter in the following:
From github's help page:

Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile path-to-private-key


In several situations I've had to set up ssh keys for remote machines that only provide me with terminal access. Thus I keep getting pestered to enter the passphrase for the ssh key. ssh-agent takes care of having to keep entering in the passphrase.

After setting up the ssh-keys do:
eval `ssh-agent`; ssh-add ~/.ssh/github_rsa

It will then ask for the passphrase the one time when it adds the key to the agent, and then wont ask again.