Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
project:git [2017/08/04 15:15]
over23 [Branches / forks] - basics documented, to be added : merging
project:git [2017/08/05 12:09]
over23 [Notes - userful commands, ToDo] notes for git
Line 1: Line 1:
-====== Git HOWTO : https://​github.com/​Labka-cz/​Irssi_scripts ​====== ​+====== Git HOWTO ====== ​
  
 |**Project owner:**| [[user:​overdrive|Overdrive]] | |**Project owner:**| [[user:​overdrive|Overdrive]] |
Line 6: Line 6:
 | **License:​** | [[https://​creativecommons.org/​licenses/​by-sa/​3.0/​|Uveďte původ-Zachovejte licenci CC BY-SA]] ​ | | **License:​** | [[https://​creativecommons.org/​licenses/​by-sa/​3.0/​|Uveďte původ-Zachovejte licenci CC BY-SA]] ​ |
  
-====== Request access to shared repo by email to Over at labka.cz ====== + 
-====== Create project from existing directory ====== +{{ project:​git_data_transport.png}}
-{{ project:​git_data_transport.png }}+
   * https://​help.github.com/​articles/​adding-an-existing-project-to-github-using-the-command-line/​   * https://​help.github.com/​articles/​adding-an-existing-project-to-github-using-the-command-line/​
   * https://​git-scm.com/​book/​cs/​v1/​%C3%9Avod-Prvn%C3%AD-nastaven%C3%AD-syst%C3%A9mu-Git - cz dokumentace ke gitu   * https://​git-scm.com/​book/​cs/​v1/​%C3%9Avod-Prvn%C3%AD-nastaven%C3%AD-syst%C3%A9mu-Git - cz dokumentace ke gitu
 +====== Create project from existing directory ======
 ===== Init directory to be used by GIT ===== ===== Init directory to be used by GIT =====
   # cd ~/directory   # cd ~/directory
Line 17: Line 16:
   # git add . -A ## add all files in repository   # git add . -A ## add all files in repository
 ===== create local ignore file ===== ===== create local ignore file =====
-* in case you want to add dot files+  ​* in case you want to add dot files
   # git add -f .gitignore   # git add -f .gitignore
   ​   ​
-===== global ignore file =====+===== or global ignore file =====
  
-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:+  * 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    git config --global core.excludesfile ~/​.gitignore
 +
 ==== example how to exclude all vim tmp files ==== ==== example how to exclude all vim tmp files ====
  * inside of .gitignore file you will be  * inside of .gitignore file you will be
 +
 <​code>​ <​code>​
 # VIM: Temperory files # VIM: Temperory files
 *~ *~
- 
 # VIM: Swap-files # VIM: Swap-files
 [._]*.s[a-w][a-z] [._]*.s[a-w][a-z]
 [._]s[a-w][a-z] [._]s[a-w][a-z]
- 
 # VIM: Commands :cs, :ctags # VIM: Commands :cs, :ctags
 tags tags
 cscope.* cscope.*
- 
 # VIM session # VIM session
 Session.vim Session.vim
- 
 # VIM: netrw.vim: Network oriented reading, writing, browsing (eg: ftp scp)  # VIM: netrw.vim: Network oriented reading, writing, browsing (eg: ftp scp) 
 .netrwhist .netrwhist
 </​code>  ​ </​code>  ​
-  ​ +===== 1st commit content to GIT =====  ​ 
-  # git commit -m "First commit"​ ## add first commit with comet to be ready to be uploaded to git[hub] +  # git commit -m "First commit"​ ## add first commit with coment ​to be ready to be uploaded to git[hub] 
-  ## create project directory on GitHub, and copy its link by buton "Clone or download"​ where you can get its URL +  # git remote add origin ​[remote repository URL or SSH link] 
-  # git remote add origin ​//remote repository URL// +  # git push -u origin master ## push you commit to remote URL repo, branch master
-  # git push -u origin master ## push you commit to remote URL repo+
  
 ====== Evey day use of Git[Hub] ====== ====== Evey day use of Git[Hub] ======
 +===== commit files to git - master =====
 +
   # cd to already inited directory   # cd to already inited directory
   # git add . -a ## or you can add just specific file   # git add . -a ## or you can add just specific file
   # git commit -m "write what is your commit about"   # git commit -m "write what is your commit about"
   # git push   # git push
-  ​ + 
-* when you want to download ​last changes from with changes from repo, to already inited dir+===== get last version of git repo ===== 
   # git pull   # git pull
   ​   ​
-====== Branches ​/ forks ======+===== Branches =====
 Original documentation : https://​git-scm.com/​book/​en/​v2/​Git-Branching-Basic-Branching-and-Merging Original documentation : https://​git-scm.com/​book/​en/​v2/​Git-Branching-Basic-Branching-and-Merging
  
Line 69: Line 68:
 2. switch to branch 2. switch to branch
    # git branch [branch_name]    # git branch [branch_name]
-   # git checkout ​iss53+   # git checkout ​[branch_name]
  
 or you can do git `checkout -b [branch_name]` or you can do git `checkout -b [branch_name]`
Line 97: Line 96:
  
   # git branch -d [another_branch_from_master]   # 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 =====
 +<​code>​
 +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
 +</​code>​
  
-====== Howto connect GitHub to IRC ====== 
-* ToDo 
-====== Howto create project WebPage directly by GitHub ====== 
-* ToDo 
  • project/git.txt
  • Last modified: 2017/11/14 07:36
  • by licho