Quantcast
Channel: Take anything, but my IDE » Git
Viewing all articles
Browse latest Browse all 2

Git tips and tricks

0
0

Display the active branch in the terminal prompt
Add this line to ~/.bashrc
PS1='\u@\h:\w$(__git_ps1 " (%s)")\$ '

Automatic add during commit
git commit -am "message"
It automatically adds already versioned files to the index before commit. This will automatically remove file disappeared from the filesystem. Untracked files will not be added.

Add to the index just some part of a file
git add --patch
For each chunk, you can type: y (stage it), n (do not stage it), q (do not stage & quit)

Interactive index add
git add --interactive
This UI has Super Cow Powers. Go in update mode with update. Now type:

1     to add the first file to the index
1-3 to add files 1, 2 and 3 to the index
-1   to unstage first file

To go back into “what now” mode, press Enter. With revert mode you can restore a file as it is in HEAD. For other modes, type help.

Undo a commit
To go back to the previous state
git reset --soft HEAD^
Fix what was wrong and commit from the discarded commit (ORIG_HEAD)
git commit -c ORIG_HEAD


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images