Skip to main content
University of California San Francisco Give to UCSF

UCSF IT Technology

Main navigation

  • Status
    • Security Announcements
  • Services
    • Projects
  • How To
  • News & Events
  • About Us
  • Log In
Open Close Search
Open menu
Give to UCSF

Breadcrumb

  1. Home
  2. How To
  3. Getting Started With Git

This content is viewable by Everyone

Getting Started with Git

Save

Log in via MyAccess to save.

  • Audience: Faculty, Staff, Student, Technical Partner
  • Service Category: Hosting & Computing
  • Owner Team: Web Services
  • Service:
    GitHub Enterprise Server (On-Premises), GitHub Enterprise Cloud

GitG=Hub offers a nice start-up guide for Git. 

A few Git GUI clients

MysysgitGUI Windows client
SourceTreeFree GIT GUI client for Windows and Mac
TowerCommercial GUI client for Mac
GitKrakenFree GIT GUI Client for Mac, Windows and Linux

Recommended Git documentation

  • http://help.github.com - some of their guide is specific to GitHub, but it is probably the best introduction to basic topics
  • http://git-scm.com/documentation - also a pretty good reference
  • http://help.github.com/git-cheat-sheets - very helpful quick guide
  • http://gitref.org/
  • http://drupal.org/documentation/git
  • http://learn.github.com/p/intro.html
  • http://progit.org/
  • http://www-cs-students.stanford.edu/~blynn/gitmagic
  • http://schacon.github.com/git/user-manual.html
  • https://code.visualstudio.com/docs/sourcecontrol/github - the official GitHub how-to for Visual Studio Code/VSCode

Getting started: Cloning the current Main or Master branch 

Make a directory for all your Git projects

  1. 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

    Example  git clone ucsfp1@svn-16694.prod.hosting.acquia.com:ucsfp1.git

  3. Set up your own branch for changes

    git checkout -b mybranch

Daily work flow

  1. Synch your local main repository to the remote main
     git pull
  2.  Add your changes to your local repository in 
    git add /docroot/sites/yoursites.ucsf.edu
  3. Commit 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"
  4. Merging your feature branch change to the remote main branch
    1. Check what branch you are in
      git status
    2. Check out the local main branch
      git checkout main
    3. Merge your changes into the local main branch
      git merge mybranch
    4. Push your changes into the remote main 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/

Justin Hileman wrote a blog post and created a visualization called "Git Pretty". The visualization is handy for navigating out of weird Git situations/messes that happen occasionally. The blog is gone, but the visualization lives on. Here's a recreation of it in Mermaid.js.

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'

 

Section Menu
GitHub Enterprise Server (On-Premises)
  • Connecting to your Git Repository from the Command line
  • GitHub Enterprise Best Practices
  • Getting Started with Git
  • Managing Passwords in Git
  • GitHub Enterprise Cloud
  • GitHub Backend Administration
  • GitHub Enterprise (on-prem) Usage
Home

Footer Col 1

  • Status
  • Services
  • How To
  • News & Events

Footer Col 2

  • About
  • IT Directory
  • Standards & Guidelines

Footer Col 3

  • Get Help
  • Recognize IT Staff
  • Submit a Support Inquiry

    For emergencies and high priority issues please call the IT Service Desk (415) 514-4100

    • Facebook
    • Twitter
    • YouTube
    • Instagram

    © 2025 The Regents of the University of California