Thomas Mullaly

DevOps, Security and IT Leadership

Git

Typical Usage

Create a new branch

git branch production
git checkout production
git merge master
git push origin production

Simple single user private hosting

If you want to use users as a simple single user repository.

ssh to users

Now create your repository:

mkdir myrepo.git
cd !$
git --bare init

The last step creates an empty repository, assuming you have a local repository that you want to push to a remote server.

Now on your local machine:

If you’ve already defined a remote origin, you’ll want to delete the remote first:

git remote rm origin

Now you can add the new remote:

git remote add origin username@users.cs.umb.edu:myrepo.git
git push origin master

Make sure you add a default merge and remote:

git config branch.master.remote origin && git config branch.master.merge refs/heads/master

Rebase

Say you’ve forked a project and want to update your clone to the forks.

git clone git@bitbucket.org:tommyfun/androidcatornotcat.git
cd androidcatornotcat/
ls
git status
git remote add upstream git@bitbucket.org:lamdersar/androidcatornotcat.git
git fetch upstream
git status
git checkout master
git rebase upstream/master
git push