Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 122013
 

How to merge a specific file from another branch in Git

Answer:

You have two branches, develop and master. The develop branch contains a lot of commits but you only want to merge a particular commit (of two files), what would you do?

You can use git cherry-pick but the easiest way to do and most people need is the following:

# git checkout master
# git checkout develop /path/to/file1
# git checkout develop /path/to/file2
..
git commit -m 'Merge changes from develop for file1 and file2'
Nov 242012
 

Fix git's fatal: index file corrupt

Answer:

When you experienced when your git repository might return the following error when you perform the status command, e.g.

# git status
error: bad index file sha1 signature
fatal: index file corrupt

To fix it, simply type

# rm -f .git/index

Then

# git reset

That's it.