Created
August 4, 2015 10:36
-
-
Save hiendinhngoc/69340ca16953c1505ba0 to your computer and use it in GitHub Desktop.
deeper git
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
- How do you amend a commit message that you just messed up? | |
git commit --amend -m "New commit message" | |
git rebase --continue -m "New commit message" | |
If you've already pushed your commit up to your remote branch, then you'll need to force push the commit with | |
git push <remote> <branch> --force | |
# Or | |
git push <remote> <branch> -f | |
- How do you view the history of your most recent commits? | |
https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History | |
- What are two different uses for $ git checkout? | |
git-checkout - Switch branches or restore working tree files | |
git checkout <branch> | |
git checkout --detach [<branch>] | |
- How do you undo a recent commit? | |
$ git commit ... (1) | |
$ git reset --soft HEAD~1 (2) | |
<< edit files as necessary >> (3) | |
$ git add .... (4) | |
$ git commit -c ORIG_HEAD (5) | |
This is what you want to undo | |
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message1, | |
or | |
both. Leaves working tree as it was before "commit". | |
Make corrections to working tree files. | |
Stage changes for commit. | |
Commit the changes, reusing the old commit message. reset copied the old head to .git/ORIG_HEAD; | |
commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows | |
you to edit it. If you do not need to edit the message, you could use the -C option instead. | |
- What are branches? | |
A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master. | |
As you initially make commits, you're given a master branch that points to the last commit you made. | |
Every time you commit, it moves forward automatically. | |
- How do you create a new branch to work on? | |
$ git checkout -b [name_of_your_new_branch] | |
- How do you push that (non-master) branch up to Github? | |
$ git push origin [name_of_your_new_branch] | |
- How do you merge the changes from your new branch into the master branch again? | |
$ git checkout master | |
$ git merge [name_of_your_new_branch] | |
- Why is working with feature branches useful? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment