Tuesday, June 28, 2016

Git - Get new recently added files but yet not commited

The following command gets all the files that you recently added but not commited yet:
$ git diff --cached --name-only --diff-filter=A
Details:
--name-only: shows all the files you changed relative to HEAD.
--name-status: to get the status symbol too.
--diff-filter=A: shows only the new recently added files.

Monday, June 27, 2016

Erase all files/directories except some of them

To erase all directories except one, execute the following:
$ find . -maxdepth 1 -not -name [file/directory_name] -exec rm -R {} \;
Where:
-maxdepth: prevents to erase recursively inside the directory to keep.

If you want to be sure that the correct files will be removed, run first the beginning part of the command(before "-exec") and when you are sure, execute the complete command:
$ find . -maxdepth 1 -not -name [file/directory_name]
If you want to keep more than one file/directory, execute:
$ find . -maxdepth 1 -not -name [file_1/directory_name_1] \
-and -not -name [file_2/directory_name_2] -exec rm -R {} \;
Where:
-and: is the logical operand and.

Shortcuts to move the cursor on a terminal command line


Ctrl + a : Moves the cursor to the line start.
.
Ctrl + e : Moves the cursor to the line end (remember e for end).

Alt + f : Moves the cursor forward one word (remember f for forward) .

Alt + b : Moves the cursor backward one word (remember b for backward) .

Ctrl + x + x: Moves the cursor to the line start and to the end again.

More details:
https://en.wikipedia.org/wiki/GNU_Readline

Friday, June 24, 2016

Thursday, June 23, 2016

Git - Checking changes on origin repository against your local

Make a fetch to update the remote branch latest version status in your repository:
$ git fetch origin [Your remote branch]
fetch does not change anything in your local repository, only updates the information against the branch selected.

Check differences with diff:
$ git diff origin/[Your remote branch]

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Search This Blog

Powered by Blogger.