Linux academy


I create a tag

git tag tag1

I see the tag list

git tag

I can create a file and commit

with this command I see the difference between the tag1 creation and now

git show tag1

I see the creation of the file

it show the tags and the commit reference

git describe --tags


show all branches

git branch -A

merge the development branch to its source branch (usually master)
—no-ff means we want to retain all the commit messages prior to the merge

git merge development --no-ff


see logs in pages

git log | more

-2 the last 2 logs
-p the difference introduced in every commit

git log -p -2

show statistics

git log --stat

the reference for each commit

git log --pretty=oneline

information about the author and the commit

git log --pretty=format:"%h: %an, %ae, %cn, %cd, - %s"

to see the branch and merge

git log --pretty=format:"%h: %an, %ae, %cn, %cd, - %s" --graph



yum install postfix
systemctl enable postfix
systemctl start postfix
#disable o set to minimun the selinux
yum install httpd

Steps to create a client server git repository

follow this guide but commit something on the repo a text file with some letters

Notes about the commands

undo the change

git checkout -f

other commands

git add .
git commit
git pull origin master
git push origin master


git commit -m 'my comment here for not open the editor'

# this is to correct a previous comment of a commit before push 
git commit --amend

some commands

git init

git add '*.txt'

git log

git push -u origin master

The -u tells Git to remember the parameters, so that next time we can simply run git push

add a remote location

git remote add origin

In this case we want the diff of our most recent commit, which we can refer to using the HEAD pointer.

git diff HEAD

this show the things commited but not yet pusched
git diff --staged

this reset the change
git reset octofamily/octodog.txt

undo the last changes, already commited or not yet commited BUT not pushed

git reset HEAD --hard

Commit in an empty repository

when you do a clone of an empy repository you obtain this

git clone ssh://git@myrepo:22/ops/vagrant-recipes
Cloning into 'vagrant-recipes'...
warning: You appear to have cloned an empty repository.

git add .
git commit -m 'comment is important'

git push 
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://git@myrepo22/ops/vagrant-recipes'

to resolve only the first commit you need to do
git push --set-upstream origin master

after you can commit normal

Analyze the git repos

install and run this command inside a git repository to do research ecc.


this open an interface to see the change from the commit the present

git difftool -y --dir-diff 831d9c78524d8a600cd18a2aa2c3369e0c636cc6

if you want to do with two different commit use the double ..

git difftool -y --dir-diff 831d9c78524d8a600cd18a2aa2c3369e0c636cc6..cc254b2337bfa01d459f28acfb2b88bc81ada7da

to use this tool you need to setup your ~/.gitconfig with this config

        tool = git-meld
        external = git-meld

and install meld

sudo aptitude install meld

undo the changes not commited

if you have your directory with some changes that you don't want add and you want to clean you need to to a stash

# git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   auth.conf

no changes added to commit (use "git add" and/or "git commit -a")

# git stash
Saved working directory and index state WIP on master: 3728347 Merged in dev (pull request #2)
HEAD is now at 3728347 Merged in dev (pull request #2)

# git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working directory clean

# git pull origin master

BUT if you have new file you need to remove manually or use some others git commands , you can check with git status

Guide to study

The amazing interactive website to try git commands (HIGHLY recommended - All levels).

The post that started it all :)

Git internals video:

Git flow wrapper script:


GitHub 15 minutes interactive git tutorial (Beginners)

Global git ignore:
Linux shell prompt + GIT:
- bash:
- bash:
- fish:
- [Add your shell here]

Pretty neat and simple to understand submodules.

Why should you consider to develop your project based on git submodules? This article explains perfectly why:

Atlassian tutorial

Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License