Using Git at UCSF

What is Git?

Git is a free/open source version control system. That is, Git manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine."

 ITS currently recommends the command line interface of Git, but you are welcome to use a Git client that suits your needs.

Git hub offers a nice start up guide for Git

What are some Git GUI clients?

Mysysgit https://git-for-windows.github.io GUI Windows client
SourceTree https://www.sourcetreeapp.com Free GIT GUI client for Windows and Mac
Tower http://www.git-tower.com Commercial GUI client for Mac
GitKraken https://www.gitkraken.com Awesome dual platform GIT GUI Client for Mac, Windows and Linux, Free with commercial options

 

 

Is there more Git documentation you recommend?

 

Getting Access to the UCSF Drupal Git Repostory

To work with our Acquia Enterprise Cloud Hosting Environment you will need to request an account using your UCSF email address from us.

You will need to tell us what Hosting environment you will be requesting access to,  Drupal 6 Multi-site or Drupal 7 Multi-site.

Once you have your account in Acquia setup you can add your RSA SSH keys to the environment:

    • Login to accounts.acquia.com
    • Goto Credentials in your User profile
    • Click the Add SSH key

For further details see this documentation:

https://docs.acquia.com/cloud/ssh/enable/add-key

 Getting started- Cloning the current Master Copy

  1. Make a directory for all your Git projects

    Example c:dev/git-projects

Open the Git command line client

  1. Change directory to the git-projects directory
    Example: cd  /c/dev/git-projects
  2. Clone the existing repository to your local machine

    D6: git clone ucsf1@svn-16694.prod.hosting.acquia.com:ucsf1.git
    D7: git clone ucsfp1@svn-16694.prod.hosting.acquia.com:ucsfp1.git
  3. Change directory into the UCSF directory
    Example cd UCSF
  4. Run a git status to confirm you have the repository
    Example git status
  5. Set up your own branch for changes
    git checkout -b mybranch

Daily Work Flow

Synch your local master repository to the remote master

git pull

 Add your changes to your local repository in 

git add /docroot/sites/yoursites.ucsf.edu

Commiting your changes

The git commit command adds you changes to the current local version of the branch.

git commit -m "my change message goes here"

Merging your branch change to the master copy

check what branch you are in

git status

Check out the master branch

git checkout master

Merge your changes into the local master branch

git merge mybranch

Merge your changes into the remote master branch

git push origin master

For When "Something Goes Wrong"

Checking  When a File was Last Changed and by Whom

git log filename

Removing a Directory Full of Files

git rm -r bad_directory/

Resetting Your Local Repository

git fetch origin

git reset --hard origin/master

Git "other"

A more readable git log of commits

alias gitp='git log --graph --pretty=format:'"'"'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"'"' --abbrev-commit'