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
project:git [2017/08/04 14:53]
over23 [project GIT] : added .gitignore example, more will follow
project:git [2017/11/14 07:36] (current)
licho
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 17:
   # 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 ===== 
-* ToDo +Original documentation : https://​git-scm.com/​book/​en/​v2/​Git-Branching-Basic-Branching-and-Merging 
-====== Howto connect GitHub ​to IRC ====== + 
-ToDo +0. you are in master 
-====== Howto create project WebPage directly by GitHub ====== + 
-* ToDo+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 
 +   <​code>​ 
 +   # git checkout master 
 +   </​code>​ 
 +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 ===== 
 +<​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>​ 
  • project/git.1501851195.txt.gz
  • Last modified: 2017/08/04 14:53
  • by over23