#Git and #SSH – Version Control System #Tips #CommandLine

git working directoryRandom  .git and SSH notes for myself for easy access form anywhere.

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance.


Git feature that really makes it stand apart from nearly every other SCM out there is its branching model.
  • How do I uncompress a file with SSH?

  • Backup all Git

  • Delete folder/files

  • How create .git on our public_html?

  • SSH How to Delete folder/files:

  • What is gitignore .gitignore?

  • How to create gitignore file?

How create .git on our public_html

Create / install git:

git init
git remote add origin https://yourRepo@bitbucket.org/RepoName/RepoName.com.git
git add .
git commit -m ‘first upload’
git push –force -u origin master

will ask for your repo password … and you done.


SSH How to Delete folder/files:

rm -rf DELETE/
Sometimes you would need to remove a file or a folder from the system. To do so using SSH, you would need to execute the appropriate command – rm.
The command in its simpliest form looks like:
rm myFile.txt myFile1.txt myFile2.txt …etc…

You would notice however that listing all files/folders that need to be deleted can be quite time consuming. Fortunately, rm accepts several arguments which can ease us. In the above example, we could type:
rm myFile*.txt

This will match all files starting with ‘myFile’ and ending in ‘.txt’
To delete a whole folder and its content recursively, you can use:
rm -rf foldername/

To delete all files/folders in the current directory, without deleting the directory itself, you would need to use:
rm -rf *


Backup all Git:

if you are in public_html:

git archive master –format=tar –output=../git-All-FILES-11-16-2015.tar

it will create backup of all .git files in root directory.


How do I uncompress a file with SSH?

If you are in the same directory that the compressed file is in. To be sure, type:
ls {enter}If the file is there, you’re ready to go. If not, type:
cd /big/dom/xdomain/www/directory/ {enter}
replacing the path with the correct path to your file.If a file ends in .zip (for example, file.zip), type:
unzip file.zipIf a file ends in .tar (e.g., file.tar), type:
tar -xvf file.tartar -xvf ALLgitFILES-11-16-2015.tarIf a file ends in .gz (for example, file.gz), type:
gzip -d file.gz

If a file ends in .tar.gz (e.g. file.tar.gz), type:
gzip -d file.tar.gz
and then
tar -xvf file.tar

If a file ends in .tgz (e.g. file.tgz), type:
tar -xvzf file.tgz

Short cuts:

git commit –a –m ‘short cut for add . and commit -m’

Git repository size from command line:

git count-objects –v

Show size in folder
ls –lh

ls –l — size, permissions, time and date of last modification, owner and group

Where am I command:


Move leverl up — cd ..

du –h report size of each folder level below – will show ALL !!

du –ms folder (how many fiels)

move from root to home

cd /home/YOURSITE/public_html

git checkout master

 git commit -m ‘reduce size’  

Most commonly used git commands are:
add – Add file contents to the index
bisect – Find by binary search the change that introduced a bug
branch – List, create, or delete branches
checkout – Checkout a branch or paths to the working tree
clone – Clone a repository into a new directory
commit – Record changes to the repository
diff – Show changes between commits, commit and working tree, etc
fetch – Download objects and refs from another repository
grep – Print lines matching a pattern
init – Create an empty git repository or reinitialize an existing one
log – Show commit logs
merge – Join two or more development histories together
mv – Move or rename a file, a directory, or a symlink
pull – Fetch from and merge with another repository or a local branch
push – Update remote refs along with associated objects
rebase – Forward-port local commits to the updated upstream head
reset – Reset current HEAD to the specified state
rm – Remove files from the working tree and from the index
show – Show various types of objects
status – Show the working tree status
tag – Create, list, delete or verify a tag object signed with GPG

See ‘git help <command>’ for more information on a specific command.

How to create gitignore file?

What is gitignore

.gitignore tells git which files (or patterns) it should ignore. It’s usually used to avoid committing transient files from your working directory that aren’t useful to other collaborators, such as compilation products, temporary files IDEs create, etc

Create useful .gitignore files for your project by selecting from 214 Operating System, IDE, and Programming Language .gitignore templates

Create useful .gitignore files for your project by selecting from 214 Operating System, IDE, and Programming Language .gitignore templates

Create useful .gitignore files for your project by selecting from 214 Operating System, IDE, and Programming Language .gitignore templates

for git ignore:
git check-ignore -v — /path/to/ignored/file

You will see the rules of your .gitignore which apply.

Sample of gitignore file for regular site:

the easiest way is to add files not directory if some files are needed:

and so on.

More to come later…

Check out our other videos http://vid.io/xqZ9
Subscribe to c0deporn http://vid.io/xqZ4

Git is a source control management system that has become very popular. But most developers still haven’t heard of it or have never used it. Most who have still think it’s difficult but in fact, it’s pretty damn easy!

In this episode, we’ll get acquainted with a quick intro to the basics of using Git with local and remote repositories. In this video you learn how to initialize repositories, track files, stage changes, branch and merge, handle merge conflicts, stash changes, pull from and commit to remote repositories like GitHub. 

Pro Git (free eBook) FREE .git book