Table of Contents

Git HOWTO

Create project from existing directory

Init directory to be used by GIT

# cd ~/directory
# git init
# git add . -A ## add all files in repository

create local ignore file

# git add -f .gitignore

or global ignore file

 git config --global core.excludesfile ~/.gitignore

example how to exclude all vim tmp files

* inside of .gitignore file you will be

# VIM: Temperory files
*~
# VIM: Swap-files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# VIM: Commands :cs, :ctags
tags
cscope.*
# VIM session
Session.vim
# VIM: netrw.vim: Network oriented reading, writing, browsing (eg: ftp scp) 
.netrwhist

1st commit content to GIT

# git commit -m "First commit" ## add first commit with coment to be ready to be uploaded to git[hub]
# git remote add origin [remote repository URL or SSH link]
# git push -u origin master ## push you commit to remote URL repo, branch master

Evey day use of Git[Hub]

commit files to git - master

# cd to already inited directory
# git add . -a ## or you can add just specific file
# git commit -m "write what is your commit about"
# git push

get last version of git repo

# git pull

Branches

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

0. you are in master

1. create new branch

2. switch to branch

 # git branch [branch_name]
 # git checkout [branch_name]

or you can do git `checkout -b [branch_name]` btw. this will cause head move forward, so `master` branch is behind head

3. create something and commit it to branch

 # git commit -a -m 'something changed [branch_name]'

4. you want to return to `master` [so switching from [branch_name] to master_branch]

   # git checkout master
   

5. you want to create another branch and again commit something there…

 # git checkout -b [another_branch_from_master]
 ....
 # git commit -a -m 'fixed and changed whatever needed'

6. merge [another_branch_from_master] to master

# git checkout master
# git merge [another_branch_from_master]

7. delete not needed branch

# git branch -d [another_branch_from_master]

8. return back to [branch_name] to finish work there and merge it to master which was changed by previous merging with [another_branch_from_master], at the end delete not needed branch agai

 # git checkout [branch_name]
 ....
 # git commit -a -m "another set of changes commit to [branch_name]
 # git checkout master
 # git merge [branch_name]
 # git branch -d [branch_name]
 

9. in case of conflicting merge you can use

 
 # git status #to see what is up
 # git mergetools
 # git status #to check if everything is fine
 # git commit

Notes - userful commands, ToDo

git add classes/system/linux/system/mon.yml -- prida jmenovite soubor
git add -A --stages All
git add . --stages new and modified, without deleted
git add -u --stages modified and deleted, without new
git commit -a -m "Addition of ext interface to monitoring server node, added system.linux.system.mon"
git log --graph
git push origin HEAD:monitoring

git checkout .  --zahodi lokalni zmeny - pred add
git reset  -- zahodi zmeni v indexu, taky zahodi nepushnute commity
git clean -f --zahodit untracked soubory - nove soubory, generovane soubory