quick recap: file:///Users/Lucy/Desktop/github-git-cheat-sheet.pdf
Everyday work : commit ->pull->if conflicts commit->push
routine to commit and push: git status->git add xx( git add '*.txt')->git commit -m 'Add all txt file'->(git remote add origin https://github.com/try-git/try_git.git->git push -u origin master)/git push(after the first time)
routine to pull:git pull origin master->git diff HEAD
routine to branch out and merge:git branch XX->git checkout
Undo: Files can be changed back to how they were at the last commit by using the command: git checkout --
Unstage
:You can unstage files by using the
git reset
command(git reset octofamily/octodog.txt). git reset
did a great job of unstaging octodog.txt, but you'll notice that he's still there. He's just not staged anymore.
Notes:
Notice how Git says changes to be committed
? The files listed here are in the Staging Area
, and they are not in our repository yet. We could add or remove files from the stage before we store them in the repository.
Think of Git's log as a journal that remembers all the changes we've committed so far, in the order we committed them
The name of our remote is origin
and the default local branch name is master
. The -u
tells Git to remember the parameters, so that next time we can simply run git push
and Git will know what to do.
In this case we want the diff of our most recent commit, which we can refer to using the HEAD
pointer
Another great use for diff
is looking at changes within files that have already been staged(git diff --staged). Remember, staged files are files we have told git that are ready to be committed. Use add to stage a file.
You can finally remove all those pesky octocats by using the git rm
command which will not only remove the actual files from disk, but will also stage the removal of the files for us.
you just need to switch back to the master
branch so you can copy (or merge
) your changes from the clean_up
branch back into the master
branch