Created
November 24, 2014 18:59
-
-
Save bosskovic/ede3cda000455b731343 to your computer and use it in GitHub Desktop.
git notes
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
# Initialize repository: | |
git init | |
# Get current status: | |
git status | |
# Add file myfile.txt: | |
git add myfile.txt | |
# Commit with a message: | |
git commit -m "adds myfile.txt" | |
# Show log: | |
git log | |
# Add remote origin: | |
git remote add origin https://github.com/path_to_repo.git | |
# Push the default local branch (master) to the remote (origin) and remember branch and remote used (-u): | |
git push -u origin master | |
# Check the changes: | |
git pull origin master | |
# Compare the changes: | |
git diff HEAD | |
# Unstage file | |
git reset myfile2.txt | |
# get rid of the changes since last commit: | |
git checkout -- octocat.txt | |
# Create branch: | |
git branch my_new_branch | |
# Change branch: | |
git checkout my_new_branch | |
# Merge branch: | |
git checkout master | |
git merge my_new_branch | |
# Delete branch: | |
git branch -d my_new_branch |
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
# Purge file from repository history | |
# filters out all files in .gitignore | |
git filter-branch --force --index-filter rm --cached --ignore-unmatch `git ls-files -i -X .gitignore` --prune-empty --tag-name-filter cat -- --all | |
# force pushes to remote | |
git push origin --force --all |
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
# Remove files from repository without deleting them from the filesystem | |
# single file | |
git rm --cached mylogfile.log | |
# directory | |
git rm -r --cached directoryName | |
# everything specified in .gitignore | |
git rm --cached `git ls-files -i -X .gitignore` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment