I am starting git
and I am looking into being more productive. My experience was in Clearcase
(mainly Windows
version).
I am looking for good patterns to increase productivity.
To give an example I configured vimdiff
as a difftool
that helps me see the differences between the my working file and the commit. But if I need e.g. to copy differences from the commit to the working file, does not seem to work. I see down the window that I am using some kind of .tmp
file and a warning that I am modifying a read-only file.
So in cases like these what setup/trick etc have you used to become more productive?
Any other tips for other cases are highly welcome

- 52,998
- 69
- 209
- 339
-
5Your question does not really belong on stackoverflow.com. But you should try the vim-fugitive plugin for very nice vim-git integration. – Daan Bakker May 24 '13 at 20:37
-
Did you try a GUI diff tool before vimdiff? Fighting against Vim's learning curve won't help you in your fight against Git's learning curve. – romainl May 24 '13 at 20:48
-
@romainl:Problem is that I don't know how to setup linux to display UI. – Cratylus May 24 '13 at 21:01
-
OK. So you are learning Linux, Vim and Git at the same time. I'm sorry for you but you are trying to do too many hard things at once: that's guaranteed failure. Scale down your plan and do things in order: Linux and bash -> Git -> Vim or Linux and bash -> Vim -> Git… – romainl May 24 '13 at 21:15
-
@romainl:No, I know a few things about all to be able to do what I need (rather slowly). For instance I know more or less what to do in command line mode, but never managed to know how the display works to open a GUI. I always thought that by the time I figured how the UI opens I would have finished in the cli mode. If you recommend a reading on this it would be nice – Cratylus May 24 '13 at 21:18
-
1What distribution do you use? Debian, Mint, Ubuntu, Crunchbang, Redhat, Gentoo and many others provide you with a workable desktop environment by default. If you don't have a DE, install one with your package manager. – romainl May 25 '13 at 04:21
-
@romainl: I `ssh` a linux server. So I haven't figured out what I need to set to open a gui – Cratylus May 25 '13 at 08:41
3 Answers
Git consists of small building blocks — commands you can build solutions for your tasks with. In some ways it's similar to using vim: you may accomplish the same task with multiple sequences of commands.
Therefore it's very important to understand how git works on the low level. I would highly suggest this article: http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
In my experience a lot of problems with git come from the lack of understanding how it works. With that knowledge you will better understand how git operates on trees, which information it tracks and what possible problems may arise.
To answer you concrete question — when using vimdiff in the current file that you've modified you may use do
command to get the corresponding changes from the original file (that's being displayed in another split). You may also select lines you want to modify in visual mode and then use :diffget
command.

- 2,071
- 15
- 18
-
I understand what you are saying and I will read the link.But how will knowing the git internals help me "grab" the block of code that I modified in the working file to become what was in the previous version. I believe `do` does not work in `git difftool` mode – Cratylus May 24 '13 at 20:42
-
`git difftool` is usually used for viewing the diff without making changes. If you need to revert some of the current changes I would suggest using vim-figutive plugin's `:Gdiff` command since you might be editing the file in the editor anyway. – egdmitry May 24 '13 at 20:56
-
Would you please explain `:diffother`? I can't find any reference to it online or in `:help`. – echristopherson May 24 '13 at 21:30
-
Sorry, I've confused `do` with `:diffget`. I guess they had to use a different name since there is already a `diffoff` command and they wanted a shortcut `:diffg` to work (with only one letter after the `diff` prefix). I've updated the answer to reflect this. – egdmitry May 24 '13 at 21:36
If you want to become more productive in Git, I would suggest learning it well:
- Watch an introduction on YouTube
- Read the git book
- Think about branching strategies
- Use it a lot
- Study the plumbing
- Start answering questions tagged
git
on stackoverflow ;)

- 42,571
- 24
- 140
- 158
Have a look at Git for Windows on Googlecode (MsysGit is the development code if you want to look under the hood).
Using git-bash, git-gui and gitk, along with setting up you editor to Notepad++ (see SO answer) can give you a lot of functionality for those times you want to retreat to the comfort zone.
Enjoy the ride.

- 1
- 1

- 13,333
- 9
- 48
- 71