Last active
June 28, 2016 04:57
-
-
Save nlenkowski/14ffe30dfb1a96cf3198 to your computer and use it in GitHub Desktop.
Useful Git commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cloning a repository | |
git clone repository-url | |
# Initializing a bare repository | |
git init | |
git remote add origin repository-url | |
# Initializing a repository in a non-empty directory and adding all existing files | |
git init | |
git add . | |
git commit -m 'Initial commit' | |
git remote add origin repository-url | |
git push -u origin master | |
# Adding a file to a repository and committing it | |
git add somefile.txt | |
git commit -m "Added somefile" | |
git push -u origin master | |
# Checking out a branch | |
git checkout somebranch | |
# Checking out a tracking branch | |
git checkout -b somebranch origin/somebranch | |
# Creating a branch based off of your current branch and pushing to remote | |
git branch newbranch | |
git push -u origin newbranch | |
# Create a branch based off of another branch | |
git checkout -b newbranch somebranch | |
# Create and checkout a new branch | |
git checkout -b newbranch | |
# Fetch commits from all branches | |
git fetch origin | |
# Fetch commits from a particular branch | |
git fetch origin somebranch | |
# Merging a branch into the current branch | |
git merge somebranch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment