This content is viewable by Everyone
Getting Started with Git
- Audience: Faculty, Staff, Student, Technical Partner
- Service Category: Hosting & Computing
- Owner Team: Web Services
GitG=Hub offers a nice start-up guide for Git.
A few Git GUI clients
Mysysgit | GUI Windows client |
SourceTree | Free GIT GUI client for Windows and Mac |
Tower | Commercial GUI client for Mac |
GitKraken | Free 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
Getting started: Cloning the current Main or Master branch
Make a directory for all your Git projects
-
Example c:dev/git-projects
Open the Git command line client
- Change directory to the git-projects directory
Example: cd /c/dev/git-projects
-
Clone the existing repository to your local machine
Example git clone [email protected]:ucsfp1.git
- Set up your own branch for changes
git checkout -b mybranch
Daily work flow
- Synch your local main repository to the remote main
git pull - Add your changes to your local repository in
git add /docroot/sites/yoursites.ucsf.edu - 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" - Merging your feature branch change to the remote main branch
- Check what branch you are in
git status - Check out the local main branch
git checkout main - Merge your changes into the local main branch
git merge mybranch - Push your changes into the remote main branch
git push origin master
- Check what branch you are in
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'