This is an old revision of the document!
Git is just your ordinary overly complicated* version control system. I'm really great at doing stuff with git
, especially things I didn't intend! :)
Here's a useful collection of ways to get yourself out of your own self-created git jams.
git status
And near the top of the output are instructions.
Warning: there is no confirmation prompt! Don't type this unless you really mean bring your local copy back in sync with the current branch!
git checkout .
From stackoverflow.
git reset <path-to-file-or-dir>
If you haven't pushed it yet, it is possible to make a new commit that is automatically merged with the previous commit. Stage the changes you need to add to the previous commit with git add
first, then:
git commit --amend
This command will open $EDITOR
for editing of the commit message and then merge the staged changes with the previous commit. To avoid editing the commit message, include –no-edit
.
git commit -m "Something terribly misguided" # oops! # this line reverts the previous commit git reset HEAD~
git diff <rev1>^..<rev2>
git merge --squash <other_branch>
Applies <other_branch>
into the current branch as a single set of staged changes which are not committed. Afterward, use git commit
as per usual.
*Compared to other version control systems.