Differences

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

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
tutorials:scmgit-intro [2011/04/30 14:46] – created clemenstutorials:scmgit-intro [2012/04/30 19:11] – minor formatting memnon
Line 11: Line 11:
 ===== Configuring your account to use git on sdf ===== ===== Configuring your account to use git on sdf =====
  
-First, you must be MetaARPA to use git.\\  Second, the git pkg installs most binaries you need in /usr/pkg/libexec/git-core. This needs to be in your PATH. The easiest solution is to edit ~/.bash_profile and ~/.bashrc to read:\\  export PATH=/usr/pkg/libexec/git-core/:${PATH}\\ \\  Now any SSH session will have the necessary git binaries in the PATH.\\+First, you must be MetaARPA to use git.   
 +Second, the git pkg installs most binaries you need in /usr/pkg/libexec/git-core. This needs to be in your PATH. The easiest solution is to edit ~/.bash_profile and ~/.bashrc to read: 
 + 
 +  export PATH=/usr/pkg/libexec/git-core/:${PATH} 
 + 
 +Now any SSH session will have the necessary git binaries in the PATH.
  
 ===== Creating a central git repository on SDF ===== ===== Creating a central git repository on SDF =====
Line 19: Line 24:
 ==== Create the server repository ==== ==== Create the server repository ====
  
-cd ~\\  mkdir git\\  mkdir myproject\\  git --bare init\\ \\  And that's it! on the server side. This remains empty until you first "push" your project to the server.+  cd ~ 
 +  mkdir git 
 +  mkdir myproject 
 +  git --bare init 
 +   
 +And that's it! on the server side. This remains empty until you first "push" your project to the server.
  
 ===== Creating your local git repository. ===== ===== Creating your local git repository. =====
  
-Let's assume you already have a project you want to start watching under git, with the files \\  ~/proj/\\  ~/proj/include\\  ~/proj/test.c\\  ~/proj/include/test.h\\ \\  First, initialize the git project:\\ \\  cd ~/proj\\  git init\\ \\  Now your repository is initialized! Time to check in your current project. First we add the files to the repository. I like to manually add each file instead of doing a "commit all" because "commit all" tends to collect files you never wanted to add to source control (object files, temp editing files, etc).\\ \\  git add test.c include/test.h\\  git commit\\ \\  If the commit failed, follow the directions onscreen to configure your username and email so git can track you as a user in the repository. \\  Now time to connect your local copy to the repository on sdf.\\ \\  git remote add origin user@sdf.lonestar.org:git/proj\\  git push origin master\\ \\  Git should ask for your password, and then tell you it uploaded the objects and that everything succeeded.\\  If not, ask on the sdf forum for advise.\\+Let's assume you already have a project you want to start watching under git, with the files      
 +  ~/proj/ 
 +  ~/proj/include 
 +  ~/proj/test.c 
 +  ~/proj/include/test.h 
 + 
 +First, initialize the git project: 
 + 
 +  cd ~/proj 
 +  git init 
 + 
 +Now your repository is initialized! Time to check in your current project. First we add the files to the repository. I like to manually add each file instead of doing a "commit all" because "commit all" tends to collect files you never wanted to add to source control (object files, temp editing files, etc). 
 + 
 +  git add test.c include/test.h   
 +  git commit 
 +   
 +If the commit failed, follow the directions onscreen to configure your username and email so git can track you as a user in the repository. 
 +Now time to connect your local copy to the repository on sdf. 
 +   
 +  git remote add origin user@sdf.lonestar.org:git/proj   
 +  git push origin master 
 +   
 +Git should ask for your password, and then tell you it uploaded the objects and that everything succeeded. 
 +If not, ask on the sdf forum for advise.
  
 ===== Copying your central repository to a client machine ===== ===== Copying your central repository to a client machine =====
  
-Last thing: Now that you have a central copy, how do you check it out? use "git clone":\\ \\  git clone ssh://user@sdf.lonestar.org:~/git/proj\\ \\+Last thing: Now that you have a central copy, how do you check it out? use "git clone": 
 +  git clone ssh://user@sdf.lonestar.org:~/git/proj
  
 ===== Backing up all your existing git repos to a remote server ===== ===== Backing up all your existing git repos to a remote server =====
  
-sdf doesn't backup your git repository.. while any cloned git tree is basically a backup it'd be nice to have an "official" backup to go along with your now "official" git server on sdf.\\  Here is a script that will, in sequence:+sdf doesn't backup your git repository.. while any cloned git tree is basically a backup it'd be nice to have an "official" backup to go along with your now "official" git server on sdf. Here is a script that will, in sequence:
  
   * check your git repo for any changes   * check your git repo for any changes
Line 84: Line 118:
   git remote add origin user@sdf.lonestar.org:git/project   git remote add origin user@sdf.lonestar.org:git/project
  
-where "origin" is the nickname for the repository on "sdf.lonestar.org". Then, you do+where "origin" is the nickname for the repository on "sdf.lonestar.org" 
 +Then, you do
  
   git fetch   git fetch
Line 90: Line 125:
 followed by followed by
  
-git merge "+  git merge 
  
 Git also provides the command "git pull" to do a fetch followed by a merge. This is unlike CVS and Subversion, where "update" works like "pull". The two commands are provided because your local repo is not meant to be a copy of the remote, so you need to be able to fetch the remote without merging it into your local repository. Git also provides the command "git pull" to do a fetch followed by a merge. This is unlike CVS and Subversion, where "update" works like "pull". The two commands are provided because your local repo is not meant to be a copy of the remote, so you need to be able to fetch the remote without merging it into your local repository.
 +
 +===== Further Reading =====
 +
 +There are quite a few good tutorials freely available on the net. Check out: 
 +  * [[http://www.webdesignerdepot.com/2009/03/intro-to-git-for-web-designers/|Intro to Git for Webdesigners]]
 +  * [[http://gitimmersion.com/|Git Immersion: Tour through the fundamentals]]
 +  * [[http://progit.org/book/|Pro Git]]
 +  * [[http://book.git-scm.com/|The Git Community Book]]
  
 ===== TODO ===== ===== TODO =====
  
-merging/branching\\  Best look online for more in-depth tutorials.. I haven't needed these features yet as my projects are all just me, so I don't know how to do it!\\ \\+  * merging/branching 
 + 
 +Best look online for more in-depth tutorials..  
 +I haven't needed these features yet as my projects are all just me, so I don't know how to do it!