Git Quick Reference - RobotGirls/FTC-Team-25 GitHub Wiki
Things to remember when working on your Git repo:
- Only make feature branches off of the master branch
- Push your code to your feature branch after every class! It's ok if your feature branch doesn't fully work. That way, if you're absent, other girls can pick up where you left off
- The master branch should be a fully working version. Use pull requests if you need to make changes to master
If you already trashed a file before using git remove
:
- The file is stored in your git repository but they are no longer part of your working directory
- You have to remove it first form the cache (index)
git rm --cached <deleted_file>
To revert uncommited changes:
- 'git clean -nd' to preview the changes, to ensure you don't unintentionally remove untracked files or directories that you care about
-
git clean -i
for interactive mode -
git clean -fd
to force remove files and directories
-
-
git checkout -- path/to/the/file.txt
undos the changes to one file in the repo- 'git checkout -- .' undos only unstaged changes in your current working directory
-
git checkout --
lists the files that will be reverted (just lists, no action taken)
- 'git reset --hard' undos both staged and unstaged changes (undos all the changes you've introduced since your last commit)
Command | Description | Example |
---|---|---|
git help |
Get help on a command | $ git help push |
git status |
Show the status of the repository | $ git status |
git branch -a |
Get a list of all available branches | $ git branch -a |
git checkout <branch name> |
Checkout a branch | $ git checkout master |
git pull |
Copy changes from a remote repository into your working directory | $ git status |
git add <name> |
Add given file or directory to staging area | $ git add foo |
git add -A |
Add all files or directories to staging area | $ git add -A |
git commit -m |
Commit staged changes with a message | $ git commit -m "Add thing" |
git commit -am |
Stage and commit changes with a message | $ git commit -am "Add thing" |
git diff |
Show diffs between commits, branches, etc. | $ git diff |
git commit --amend |
Amend the last commit | $ git commit --amend |
git show <SHA> |
Show diff vs. the SHA | $ git show fb738e… |