Last active
December 19, 2016 17:04
-
-
Save PalashBansal/59d8119be3c1e963f2fe1827857bc9ac to your computer and use it in GitHub Desktop.
git help
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
#1 | |
# http://stackoverflow.com/questions/134882/undoing-a-git-rebase | |
-------------------------------------------------------------------------------------------------------------------- | |
#2 | |
# after squashing multiple commits into 1 commit, using interactive rebase tool | |
# have to force push them to override previous commits synced in PR (simple push doesn't work) | |
# don't use command- "git push origin master --force" (it is risky / for advanced user / doesn't work in this context) | |
# use simple command- | |
git push --force | |
# NOTE: This command should be used after checking out branch containing changes. | |
-------------------------------------------------------------------------------------------------------------------- | |
#3 | |
#COPIED FROM SOMEWHERE ELSE | |
#git squash last two commits into one | |
# squash-commits.sh | |
git rebase --interactive HEAD~2 | |
# we are going to squash c into b | |
pick b76d157 b | |
pick a931ac7 c | |
# squash c into b | |
pick b76d157 b | |
s a931ac7 c | |
# after that just edit the commit message | |
# This is a combination of 2 commits. | |
# The first commit's message is: | |
b | |
# This is the 2nd commit message: | |
c | |
-------------------------------------------------------------------------------------------------------------------- | |
#4 | |
#COPIED FROM SOMEWHERE ELSE | |
#Undo a git rebase. | |
# reflog.sh | |
# Solution found here: http://stackoverflow.com/questions/134882/undoing-a-git-rebase | |
# The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the reflog... | |
git reflog | |
# and to reset the current branch to it (with the usual caveats about being absolutely sure before reseting with the --hard option). | |
# Suppose the old commit was HEAD@{5} in the ref log | |
git reset --hard HEAD@{5} | |
-------------------------------------------------------------------------------------------------------------------- | |
#5 | |
#safe commands(just to see info.)- | |
# to see history of commands | |
git reflog | |
# | |
git log | |
# | |
git diff | |
# | |
git status | |
# to see environment(env) variable value(similar as cmd/shell commands) | |
echo $HOME | |
# | |
-------------------------------------------------------------------------------------------------------------------- | |
#6 | |
#other commands(can be unsafe)- | |
# to push to origin(forked repo) | |
git push | |
# to pull from main repo/ upstream repo(community repo) | |
git pull upstream master | |
# to pull changes from your forked repo | |
git pull origin master | |
# | |
git pull | |
# | |
git merge | |
# | |
git fetch origin | |
# | |
git diff HEAD | |
# | |
git checkout master | |
# | |
git push --force | |
# | |
git update-index --assume-unchanged PowerEditor/visual.net/ClassDiagram.cd | |
# | |
git rebase --abort | |
# | |
git remote add upstream https://github.com/notepad-plus-plus/notepad-plus-plus.git | |
# | |
git fetch upstream | |
# | |
git rm --cached PowerEditor/visual.net/notepadPlus.vcxproj | |
# | |
git clone https://github.com/git/git | |
# | |
-------------------------------------------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment