Wednesday, July 23, 2014

Git Merge

Recently I had a problem when using git.

The thing is that I tend to learn something only when I need it. So I know the basic functionality of git. It works quite well for me.

The problem came when I modified a file, and before committing it, that file is already updated by my friend. This is hard feeling for computer I guess, since he would not know which version to keep if I want to commit my change.

But I don't want my change in that file. However I am not able to commit other changes, nor can I pull or push. I solved this by doing the following things:

git checkout source_branch(usually it's master) filepath (check this out will update the file I modified to match the version in the index tree)

git reset filepath

git add -p filepath

git commit -m "merge the changes"

Update: use this one: git checkout master .

No comments:

Post a Comment