-
-
Save areinisc/2628469 to your computer and use it in GitHub Desktop.
Git Workflow
This file contains 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
# GIT WORKFLOW | |
# (c) Luke Maciak | |
# Initialize: | |
git init | |
# Check Out: | |
git clone username@host:/path/to/repository | |
# Add Origin: | |
git remote add origin <server> | |
# Commit: | |
git add file.ext # add a single file | |
git add . # add everything | |
git commit -m "Commit Message" # commit with message | |
git commit -a # add all, write long msg | |
# Stashing (when you made changes and forgot to pull for example): | |
git stash # saves current state for later use | |
git stash apply # restores/merges stashed state | |
# Remove / Stop tracking a file: | |
git rm --cached <filename> | |
# Push (upload changes to remote repository): | |
git push origin master | |
# Pull (update from remote repository): | |
git pull origin master # for master branch | |
git pull origin branchname # for specific branch | |
# If you want to be able to just do git push, git pull: | |
git config branch.master.remote origin | |
git config branch.master.merge refs/heads/master | |
# Drop all local changes and commits: | |
git fetch origin | |
git reset --hard origin/master | |
git checkout -- <file> # drops only changes for <file> | |
#Branching: | |
git checkout -b branchname # create new branch | |
git checkout master # switch back to master | |
git branch -d branchname # delete branch | |
git push origin branchname # push branch | |
git merge branchname # merge branchname into current | |
# Tagging: | |
git tag -a 1.1 -m "tag description" # regular tag | |
git tag 1.1 # lightweight tag | |
git tag 1.1 9fceb02 # tag specific commit | |
git push --tags # push tags | |
git tag -d 1.0 # delete local tag | |
git push origin :refs/tags/1.0 # delete tag from remote | |
# Adding a Submidule | |
git submodule add usename@host:/path/to/repo foldername | |
# Initializing sumbodule in a cloned project | |
git submodule init | |
git submodule update | |
# Rebasing | |
git rebase -i HEAD~3 # rebase last 3 commits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment