git stash

I feel like stash is another commits tree, but only one node. This is used for temporarily store away your current work directory.

When you type

This will firstly check if your work directory matches your commits or your stash. If not, it will gives you some error

Then, if you git stash your current work directory, if will allow you pull

git stash pop throws away the (topmost, by default) stash after applying it, whereas git stash apply leaves it in the stash list for possible later reuse (or you can then git stash drop it).

reset vs checkout

First I need to say, I understand the terminologies as

work directory: your current source code

stage: a cache copy of the code; "commit" usually are from this cache

commits: more officially history records of your previous code and those records are made through your "git commit" commands

 

 

Each branch has a tip pointer like "master","development". When you do

it moves the current pointer (unfortunately, this pointer is called "HEAD") to the branch tip of <branch_name>. This changes show up in your work tree (which refers to your real coding files).

Similarly, the following command will bring your code back to a previous specified time point.

As you still have all your commits, you can revert your coding files back to the another branch tip namely the <branch_name>.

However, this is different for git reset

reset, will move the tip pointer <branch_name> to <to_point>., whose default value is HEAD (current position).

Then you lost all the commits between <to_point> and the "old" <branch_name>.

--soft-- means change the commits only,

--mix-- (default) change both commits and stage, but leave your current source code untouched

--hard--change everything and you will have no way to revert this change

 

 

 

 

Git init

initialize the git project

then add the files you want to track

create records by

create a new remote called origin located at git@github.com:peter/first_app.git (I understand "remote" as a symbolic link pointing to the remote directory "git@github.com:<user_name>/<app_name>.git")

after you have the "remote", you can "push" the commits to it, where master is the main branch of your project.

 

Github notes

"Changes not staged for commit" ?

The files are already added to Git to be monitored, but the changes are not added to be committed. To be add, it needs

This allows the changes to be recorded for multiple commits separately.

For example, let's say you have file a, file b . You modify file a and file b , but you don't want all of them to be in one single commit. You type

As a side note, if you want to commit everything you can just type