GIT - HowTo's about "setup"


How to setup a Git distributed workflow ?

  1. As root :
    1. create a git user belonging to the git group.
    2. create accounts for the Git users. Make them belong to the primary group git :
      • at creation time : adduser -g git ... other options ...
      • or afterwards : usermod -g git bob
  2. As git :
    1. Create a directory for a new repository : mkdir /home/git/myRepo.git
      this will be a bare repository, so don't forget the trailing .git in the name of the directory.
    2. Create a new bare repository there :
      cd /home/git/myRepo.git; git init --bare
      which will output :
      Initialized empty Git repository in /home/git/myRepo.git/
  3. As bob :
    1. Make your 'development' directory tree (if any), and cd there
    2. git clone file:///home/git/myRepo.git/
      Which will output :
      Initialized empty Git repository in /home/bob/development/myRepo/.git/
      warning: You appear to have cloned an empty repository.
      • the warning is normal since it's a new repo
      • this creates the directory /home/bob/development/myRepo/ This is your working copy : it has a .git/
      • this also creates the remotes automatically
    3. Code then push your work to the central repository : git push origin master -u To let this work, you may have to chmod -R g=rwx /home/git/myRepo.git
    4. Get updates from the central repository : git pull origin master -f

How to specify the private key file to use while doing Git over SSH ?

Add into ~/.ssh/config :
Host hostAlias
	Hostname hostName
	User userName
	IdentityFile ~/.ssh/myPrivateKeyFile

How to create a new, empty, Git repository and store it on GitHub ?

Starting from GitHub :

  1. Create a new repository within GitHub web UI
  2. On the workstation, enter the parent directory of the project : cd /path/to/devDirectory/allMyProjects
  3. git clone
  4. Work hard, add / modify files, then commit
  5. Then push to GitHub : git push -u origin master
  6. If this prompts for login/pass, edit /path/to/devDirectory/allMyProjects/projectName/.git/config :
    change : url =
    into : url =
    And it should work (source : 1, 2)

Starting from the workstation :

  1. mkdir projectName;cd projectName
  2. git init
  3. Declare remote (GitHub) repository (unless already created in the GitHub Web UI) :
    git remote add origin