Create project from existing directory

# cd ~/directory
# git init
# git add . -A ## add all files in repository
  • in case you want to add dot files

# git add -f .gitignore

  • If you want to do it globally, you can create a .gitignore file in your home (you can give it other name or location), and use the following command:
 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
# VIM: Commands :cs, :ctags
# VIM session
# VIM: netrw.vim: Network oriented reading, writing, browsing (eg: ftp scp) 
# 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]

# 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
# git pull

Original documentation :

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]

  • you cannot switch, if there is something un-commited in actual working dir [you can stash in that case]
  • in this moment complete working directory will change to state as it was before you added changes in [branch_name] - so you are back in state of original 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
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