Intelligent and Interactive Systems

User Tools

Site Tools


collab:git

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
Next revision Both sides next revision
collab:git [2011/12/12 08:13]
c7031007
collab:git [2016/02/26 18:41]
c7031007 [Git]
Line 1: Line 1:
 ====== Git ====== ​ ====== Git ====== ​
 +
 Git is an extremely powerful and flexible revision control system, and using it effectively requires adherence to conventions. Git is an extremely powerful and flexible revision control system, and using it effectively requires adherence to conventions.
  
Line 5: Line 6:
  
   * A distinct tree / a repository - is maintained for each independent (software, paper, ...) project.   * A distinct tree / a repository - is maintained for each independent (software, paper, ...) project.
-  * For each project, the mainline (master) tree is hosted ​here at the iis uibk servers.+  * For each repository, the mainline (master) tree is hosted ​on the IIS server.
   * Contributors develop locally and maintain their own trees, and push (or request to pull) only generally-useful,​ tried-and-proven patch sets into the main tree.   * Contributors develop locally and maintain their own trees, and push (or request to pull) only generally-useful,​ tried-and-proven patch sets into the main tree.
   * Where appropriate,​ multiple external developers can exchange patches among each others before committing to the mainline.   * Where appropriate,​ multiple external developers can exchange patches among each others before committing to the mainline.
Line 11: Line 12:
  
  
 +Please adhere to basic guidelines for [[git-usage]].
 ===== Basic Workflow ===== ===== Basic Workflow =====
 +
  
 {{ :​collab:​git-usage.png?​300|git std. usage}} {{ :​collab:​git-usage.png?​300|git std. usage}}
Line 17: Line 20:
 Retrieve an %%IIS%% Git tree for you to work on: Retrieve an %%IIS%% Git tree for you to work on:
  
-  git clone ssh://​iis.uibk.ac.at:2222/​projects/​git/​PROJECTNAME+  git clone ssh://​iis.uibk.ac.at/​projects/​git/​PROJECTNAME 
 +   
 +''​PROJECTNAME''​ will typically include a path portion.
  
 Prepend the hostname with ''​USERNAME@''​ if your Git username does not match your local username. Prepend the hostname with ''​USERNAME@''​ if your Git username does not match your local username.
Line 42: Line 47:
 For more information,​ see the [[http://​gitref.org/​|Git Reference]] and [[http://​www.kernel.org/​pub/​software/​scm/​git/​docs/​everyday.html|Everyday Git]]. For more information,​ see the [[http://​gitref.org/​|Git Reference]] and [[http://​www.kernel.org/​pub/​software/​scm/​git/​docs/​everyday.html|Everyday Git]].
  
 +A ''​git pull''​ will automatically merge any edits other people have pushed in the meantime. ​ However, this will fail if such edits happened in the same section of a file as the changes you are trying to push.  In this case, ''​git pull''​ will signal a merge conflict, which needs to be resolved by hand.
  
-==== Comparison ​to Subversion ====+[[http://​www.rosipov.com/​blog/​use-vimdiff-as-git-mergetool/​|Here]] you may find a nice tutorial on how you can do merging by using vimdiff (you should be able to use vim for using it).
  
-Heretwo key distinctions from SVN are+ 
 +==== Creating a New Git Project ==== 
 + 
 +To create your personal Git repository for your ownlocal use only: 
 + 
 +  cd PROJECTROOT 
 +  git init --shared 
 +  git add . 
 +  git commit -m "​initial import"​ 
 + 
 +To create a Git repository on the IIS server: 
 + 
 +  - Decide on a name and a place for the repository under ''/​projects/​git/''​. It should live inside the appropriate subdirectory (''​papers/'',​ ''​projects/'',​ etc.), and should follow the repository naming conventions. For example, repositories holding published papers should be named by [[:​intranet:​public:​papers#​publication_ids|Publication ID]]. Use ''/​projects/​git/​personal/''​ only for material that is not and will not be useful to the lab. 
 +  - [[intranet:​systems:​docs:​git-ssh#​creating_a_shared_git_repository|Initialize]] your new repository on the lab server. 
 +  - Inside the newly-created repository directory on the server, edit the ''​description''​ file. This is diplayed e.g. [[:​intranet:​git-repos|here]]. 
 +  - [[#​basic_workflow|Clone and populate]] your new repository. 
 + 
 + 
 +===== Understanding Git ===== 
 + 
 +[[http://​eagain.net/​articles/​git-for-computer-scientists/​|Here]] is an excellent and brief explanation of Git's internal representation and how it supports user-level interactions. ​ Very useful to understand Git. 
 + 
 + 
 +Two key distinctions from Subversion (SVNare
  
   * the //staging area// ("​index"​) where you define the changes to be commited. (SVN commits directly from the working directory.)   * the //staging area// ("​index"​) where you define the changes to be commited. (SVN commits directly from the working directory.)
Line 60: Line 89:
 {{ :​collab:​git_revisions_without_branches.png?​400|git revisions wo branches}} {{ :​collab:​git_revisions_without_branches.png?​400|git revisions wo branches}}
  
 +  ​
 +==== Moving or Renaming a Git Repository ====
  
-==== Creating a New Git Project ====+Git repository does not know its own name or location; it is simply identified by its location in the filesystem. ​ It can be moved or renamed ad libitum.
  
-To create a shared Git repository[[intranet:systems:​docs:​git-ssh#​creating_a_shared_git_repository|initialize it on the lab server]]. ​ Then, [[#​basic_workflow|clone and populate]] it.+To keep any cloned copies in syncyou have essentially two options:
  
-To create your personal Git repository for your ownlocal use only:+  * Commit and push everything before the movedelete the clone, move the repo on the server, and create a fresh clone.
  
-  ​cd PROJECTROOT +  ​* Point an existing clone to the updated location: From the root directory of the cloned tree, issue <​html><​pre class="​code">​git remote set-url origin ssh://​iis.uibk.ac.at/​projects/​git/​SUBDIR/​REPONAME</​pre></​html>​ See [[http://​stackoverflow.com/​a/​2432799|here]] and ''​man ​git-remote''​ for more information.
-  ​git init --shared +
-  ​git add . +
-  ​git commit ​-m "​initial import"​+
  
 ==== Textmode Tool For Git ==== ==== Textmode Tool For Git ====
 a nice (commandline) tool for viewing commits, logs, diffs and other changes is tig. to install tig on a debian based machine a nice (commandline) tool for viewing commits, logs, diffs and other changes is tig. to install tig on a debian based machine
-  ​aptitude ​install tig+  ​apt install tig
 change into the git working directory and start change into the git working directory and start
   tig   tig
Line 102: Line 130:
 Host iis Host iis
     HostName iis.uibk.ac.at     HostName iis.uibk.ac.at
-    Port 2222+    Port 22
     User username     User username
     #​IdentityFile ​ ~/​.ssh/​PRIVATEKEYFILE ​     #​IdentityFile ​ ~/​.ssh/​PRIVATEKEYFILE ​
Line 112: Line 140:
   git clone ssh://​iis/​projects/​git/​projectname   git clone ssh://​iis/​projects/​git/​projectname
  
 +{{tag>​git Usage}}
  
  
collab/git.txt · Last modified: 2018/09/03 19:35 (external edit)