- http://stackoverflow.com/questions/804115 (
rebase
vsmerge
). - https://www.atlassian.com/git/tutorials/merging-vs-rebasing (
rebase
vsmerge
) - https://www.atlassian.com/git/tutorials/undoing-changes/ (
reset
vscheckout
vsrevert
) - http://stackoverflow.com/questions/2221658 (HEAD^ vs HEAD~) (See
git rev-parse
) - http://stackoverflow.com/questions/292357 (
pull
vsfetch
) - http://stackoverflow.com/questions/39651 (
stash
vsbranch
) - http://stackoverflow.com/questions/8358035 (
reset
vscheckout
vsrevert
)
Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}
Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:
The goal of this gist is to provide a list of the most common/useful shell commands.
command | stands for | common usage | description |
---|---|---|---|
man |
manual | man | display the man page for the given comand. If you're wondering how to use any command, this is the go-to place for help. It provides information about what the command does, how to use it, what flags it has, and lots more. |
<command> --help |
While it's not an actual command, I thought it'd be useful to include it. While man will get you the most thorough information about a command, many commands don't provide man pages. Also sometimes it's useful to get a less verbose help message. In those cases, --help /-h is what you want. |
||
<command> -h |
^ see above ^ | ||
cd |
change directory | cd |
move to the given directory |
# The OAuth access token provided by the Google API expires in 60 minutes. After expiration, | |
# you must exchange a refresh token for a new access token. Unfortunately, the the Google API | |
# ruby gem does not include a method for refreshing access tokens. | |
# You can read up on how to refresh an access token here: | |
# https://developers.google.com/accounts/docs/OAuth2WebServer#refresh | |
# This Token model implements that process. It's based off of a Token model that can be created | |
# by running: | |
# rails g model Token token:text refresh_token:string expires_at:datetime |
# Link: <http://example.com/resources?page=2>; rel="next", <http://example.com/resources?page=5>; rel="last" | |
links = {} | |
headers['Link'].split(',').each do |link| | |
link.strip! | |
parts = link.match(/<(.+)>; *rel="(.+)"/) | |
links[parts[2]] = parts[1] | |
end |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |