Skip to content

Instantly share code, notes, and snippets.

@uccmen
Last active January 2, 2016 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uccmen/8265730 to your computer and use it in GitHub Desktop.
Save uccmen/8265730 to your computer and use it in GitHub Desktop.
Notes about Git at work
# Creates a new branch called "mybranch"
# Makes "mybranch" the active branch
git branch mybranch
git checkout mybranch
OR
# Creates a new branch called "mybranch" and makes it the active branch
git checkout -b mybranch
#To switch between branches, use git checkout.
# Makes "master" the active branch
# Makes "mybranch" the active branch
git checkout master
git checkout mybranch
#Once you're finished working on your branch and are ready to combine it back into the master branch, use merge.
# Makes "master" the active branch
# Merges the commits from "mybranch" into "master"
# Deletes the "mybranch" branch
git checkout master
git merge mybranch
git branch -d mybranch
## Creating a remote repo on Github via the command line
## Remember replace USER with your username and REPO with your repository/application name!
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin git@github.com:USER/REPO.git
git push origin master
Step 1: Fork the target repository on Github
Press the fork button
Step 2: Clone your fork
git clone https://github.com/username/Spoon-Knife.git
Step 3: Configure remotes
cd Spoon-Knife
# Changes the active directory in the prompt to the newly cloned "Spoon-Knife" directory
git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repository to a remote called "upstream"
git pull upstream master
# Pulls commits from 'upstream' and stores them in the local repository
OR
git fetch upstream
# Pulls in changes not present in your local repository, without modifying your files
git merge upstream/master
# Merges any changes fetched into your working files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment