User Tools

Site Tools


scmgit-intro

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scmgit-intro [2021/03/12 22:07] – [Introduction] hc9scmgit-intro [2024/09/16 07:39] (current) – it” hc9
Line 3: Line 3:
 ===== Introduction ===== ===== Introduction =====
  
-git is a [[wp>Revision_control|source control management]] tool similiar to CVS or SVN. This tutorial will give enough information to:+git is a [[wp>Version_control|source control management]] tool similiar to CVS or SVN. This tutorial will give enough information to:
  
   * create a central git repository on your MetaARPA account   * create a central git repository on your MetaARPA account
Line 10: Line 10:
   * create a public readonly copy of your repository   * create a public readonly copy of your repository
  
-The best reason why a person would use git instead of cvs or svn is that git does not require a central server. For example, let's say you were taking out a CVS repository to your laptop and would not be able to connect to the server for a month. When you get back, that entire months worth of work is seen as a single diff. Which you would have to merge by hand to the other changes, but also you couldn't differentiate between reasons you changed files. For example, let's say you fixed a bug and added a new feature. Which filechanges were for the new feature? Which for the bugfix? CVS has no clue. Enter git. You can locally "commitchanges without talking to the server, so you could have done a commit after the new feature and a commit after the bug fix and to the repository they are two unique changes.+The best reason why a person would use git instead of cvs or svn is that git does not require a central server. For example, let's say you were taking out a CVS repository to your laptop and would not be able to connect to the server for a month. When you get back, that entire months worth of work is seen as a single diff. Which you would have to merge by hand to the other changes, but also you couldn't differentiate between reasons you changed files. For example, let's say you fixed a bug and added a new feature. Which filechanges were for the new feature? Which for the bugfix? CVS has no clue. Enter git. You can locally commit” changes without talking to the server, so you could have done a commit after the new feature and a commit after the bug fix and to the repository they are two unique changes.
  
 ===== Configuring your account to use git on sdf ===== ===== Configuring your account to use git on sdf =====
Line 26: Line 26:
 ===== Creating a central git repository on SDF ===== ===== Creating a central git repository on SDF =====
  
-I suggest creating a subdirectory that will hold nothing but your git repositories.. let's say it's ~/git. The server copy of the git repository need not be a useable repository (IE, the files under revision control do not need to exist.. we just need the git database to exist so we can clone from it). Under git this is called a "barerepository.+I suggest creating a subdirectory that will hold nothing but your git repositories.. let's say it's ~/git. The server copy of the git repository need not be a useable repository (IE, the files under revision control do not need to exist.. we just need the git database to exist so we can clone from it). Under git this is called a bare” repository.
  
 ==== Create the server repository ==== ==== Create the server repository ====
Line 36: Line 36:
      
 </code> </code>
 +
 Note that the path is arbitrary and can be anywhere in your home directory. This can be done either on the Meta Array or on the main cluster. Note that the path is arbitrary and can be anywhere in your home directory. This can be done either on the Meta Array or on the main cluster.
  
-And that's it! on the server side. This remains empty until you first "pushyour project to the server.+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. =====
Line 56: Line 57:
      
 </code> </code>
-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 allbecause "commit alltends to collect files you never wanted to add to source control (object files, temp editing files, etc).+ 
 +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).
  
 <code> <code>
Line 63: Line 65:
      
 </code> </code>
 +
 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. 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.
  
Line 72: Line 75:
      
 </code> </code>
 +
 Or, if you created your repo on the Meta Array, set up your remotes like this: Or, if you created your repo on the Meta Array, set up your remotes like this:
  
Line 79: Line 83:
      
 </code> </code>
 +
 Git should ask for your password, and then tell you it uploaded the objects and that everything succeeded.\\ 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. If not, ask on the sdf forum for advise.
Line 94: Line 99:
 ===== 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 "officialbackup to go along with your now "officialgit server on sdf.\\+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: Here is a script that will, in sequence:
  
Line 130: Line 135:
 fi fi
 </code> </code>
-Note: For the FTP to work, edit your ~/.netrc file so that ftp.your-host.com has an entry that looks like:\\ 
  
 +Note: For the FTP to work, edit your ~/.netrc file so that ftp.your-host.com has an entry that looks like:
  
 <code> <code>
Line 139: Line 144:
     bin     bin
 </code> </code>
-Also ensure to run "chmod 600 ~/.netrcto hide your credentials to the rest of the world :). Now add this to your (daily or less) cron tasks with mkcron (MetaARPA only, just like git ;) and enjoy your timely backups!+ 
 +Also ensure to run chmod 600 ~/.netrc” to hide your credentials to the rest of the world :). Now add this to your (daily or less) cron tasks with mkcron (MetaARPA only, just like git ;) and enjoy your timely backups!
  
 ===== Updating your local copy with changes made to the repo ===== ===== Updating your local copy with changes made to the repo =====
Line 160: Line 166:
  
 Once you have your repo setup for you to do your work in, you may have a need to make your work public. Making it public allows for other users to pull specific version of your project without having to have development rights. A slight modification to your repo is needed and some webspace to host it.\\ Once you have your repo setup for you to do your work in, you may have a need to make your work public. Making it public allows for other users to pull specific version of your project without having to have development rights. A slight modification to your repo is needed and some webspace to host it.\\
- 
  
 ==== Setup some webspace ==== ==== Setup some webspace ====
Line 167: Line 172:
 \\ \\
 ''%%mkdir ~/html/devel%%''\\ ''%%mkdir ~/html/devel%%''\\
- 
  
 ==== hooks/post-update ==== ==== hooks/post-update ====
  
-In your repo directory for the project there is a directory that contains a set of scripts which are called at different times during your interaction with git. For more information about the "hooksdirectory check out [[http://www.kernel.org/pub/software/scm/git/docs/githooks.html|githook]].+In your repo directory for the project there is a directory that contains a set of scripts which are called at different times during your interaction with git. For more information about the hooks” directory check out [[http://www.kernel.org/pub/software/scm/git/docs/githooks.html|githook]].
  
 The script we will need to modify is post-update. This script is called after an update has occured on the server side of your repo. The script we will need to modify is post-update. This script is called after an update has occured on the server side of your repo.
Line 234: Line 238:
 $ $
 </code> </code>
-In the above example there is a new line labled "remotewhich means that during the push, the server produced output. The line matches the last line in our post-update script. Now you have two methods of access.+ 
 +In the above example there is a new line labled remote” which means that during the push, the server produced output. The line matches the last line in our post-update script. Now you have two methods of access.
  
 **Private Access:** git clone user@sdf.org:~/git/proj.git\\ **Private Access:** git clone user@sdf.org:~/git/proj.git\\
Line 272: Line 277:
 sdf-dev sdf-dev.pub sdf-dev sdf-dev.pub
 </code> </code>
 +
 ==== Create a git access script ==== ==== Create a git access script ====
  
Line 280: Line 286:
 exec git-shell -c "$SSH_ORIGINAL_COMMAND" exec git-shell -c "$SSH_ORIGINAL_COMMAND"
 </code> </code>
 +
 The ''%%$SSH_ORIGINAL_COMMAND%%'' variable contains the commands issued with your ssh session (try logging in with ''%%ssh localhost ls%%''). The ''%%$SSH_ORIGINAL_COMMAND%%'' variable contains the commands issued with your ssh session (try logging in with ''%%ssh localhost ls%%'').
  
Line 289: Line 296:
 command="/arpa/gm/f/frank/gitaccess.sh",no-port-forwarding,no-agent-forwarding,no-x11-forwarding,no-pty ssh-rsa AAAB3... command="/arpa/gm/f/frank/gitaccess.sh",no-port-forwarding,no-agent-forwarding,no-x11-forwarding,no-pty ssh-rsa AAAB3...
 </code> </code>
 +
 All the ''%%no-*%%'' flags disable all other types of ssh access (Port Forwarding, X11, PTY) so we only get git access and nothing else. Now if your friend uses your user name and his/her ssh key to connect to your git server they will be able to clone, pull, commit, etc. just as if they were you. Make sure they set their global settings in their git client so you can see your history correctly. All the ''%%no-*%%'' flags disable all other types of ssh access (Port Forwarding, X11, PTY) so we only get git access and nothing else. Now if your friend uses your user name and his/her ssh key to connect to your git server they will be able to clone, pull, commit, etc. just as if they were you. Make sure they set their global settings in their git client so you can see your history correctly.
  
Line 295: Line 303:
 merging/branching\\ 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!\\ 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!\\
-\\ 
- 
  
 $Id: scmgit-intro.html,v 1.11 2020/01/01 22:52:17 niro Exp $ $Id: scmgit-intro.html,v 1.11 2020/01/01 22:52:17 niro Exp $
Line 306: Line 312:
  
 Originally appeared at https://sdf.org/?tutorials/scmgit-intro Originally appeared at https://sdf.org/?tutorials/scmgit-intro
 +
scmgit-intro.1615586859.txt.gz · Last modified: 2021/03/12 22:07 by hc9