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]

Wednesday, June 22, 2016

Git - Commit project to new branch

Create a new branch and move your project to it:
$ git checkout -b [New Branch]
If you have modified or created files, add them to the project:
$ git add [Your modified or new files]
Commit your changes:
$ git commit -m '[Your Comments]'
Push the project to the new branch:
$ git push origin [New Branch]


See also: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Monday, June 13, 2016

Friday, June 10, 2016

Install Sublime Text 3

Download Sublime Text 3:
wget https://download.sublimetext.com/sublime_text_3_build_3114_x64.tar.bz2
Uncompress tarball:
sudo tar vxjf sublime_text_3_build_3114_x64.tar.bz2
Move sublime directory to /opt:
sudo mv sublime_text_3 /opt/
Create symbolic link to sublime:
sudo ln -s /opt/sublime_text_3/sublime_text /usr/bin/sublime
Execute sublime and enjoy!:
sublime

Thursday, June 9, 2016

Git - Steps to commit a project

1. Show the status(how many new files, deleted files, modified files, etc.):
$ git status
2. Add all files to the project:
$ git add -A
the -A option means track all including deleted files.

3. Commit:
$ git commit -m "[Comments]"
the -m option gives you the possibility to add your comments in the same line.

4. Push:
$ git push -u origin master
The -u is optional and what it does is sets your local repo to a central one in order to, in the next time, git knows where to push and pull from.

For basic snapshotting see:
http://gitref.org/basic/

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Search This Blog

Powered by Blogger.