Staging Changes: Git New Notes
Staging Changes: Git New Notes
Staging Changes
Now that you've added or modified some files, you need to stage those commits into
"the staging area." Think of git commits like an array of airlock hatches on a space ship.
On this space ship, you can only open the door to one airlock at a time. When you open
the hatch, you can put stuff in or take stuff out at will. Not until you've closed the door
have you committed those changes (git commit) and not until you hit the red button do
all those hatches open up into space (git push).
Unstaging Changes
Maybe you accidentally staged some files that you don't want to commit.
Commits
Commit often. You can always squash down your commits before a push.
Undoing Commits
The following command will undo your most recent commit and put those changes
back into staging, so you don't lose any work:
Squashing Commits
Maybe you have 4 commits, but you haven't pushed anything yet and you want to put
everything into one commit so your boss doesn't have to read a bunch of garbage
during code review.
Pushing
Push a local branch for the first time:
Fetching
Fetch changes from upstream: