[https://medium.com/@lucasmaurer/git-gud-the-working-tree-staging-area-and-local-repo-a1f0f4822018]
사실 이 검색어로 검색했다. "git difference between stage local working area"
There are three core areas to git. These are the Working Tree, the Staging Area (also known as Index), and the Local Repository. When working in a git repository files and modifications will travel from the Working Tree to the Staging Area and finish at the Local Repository. Thus we will talk about these three areas in that order.
The Working Tree
The Working Tree is the area where you are currently working. It is where your files live. This area is also known as the “untracked” area of git. Any changes to files will be marked and seen in the Working Tree. Here if you make changes and do not explicitly save them to git, you will lose the changes made to your files. This loss of changes occurs because git is not aware of the files or changes in the Working Tree until you tell it to pay attention to them. If you make changes to files in your working tree git will recognize that they are modified, but until you tell git “Hey pay attention to these files,” it won’t save anything that goes on in them.
How can you see what is in your Working Tree? Run the command git status. This command will show you two things: The files in your Working Tree and the files in your Staging Area. It will look something like the image below if you don’t have anything in your Staging Area.
The Staging Area (Index):
The Staging Area is when git starts tracking and saving changes that occur in files. These saved changes reflect in the .git directory. That is about it when it comes to the Staging Area. You tell git that I want to track these specific files, then git says okay and moves them from you Working Tree to the Staging Area and says “Cool, I know about this file in its entirety.” However, if you make any more additional changes after adding a file to the Staging Area, git will not know about those specific changes until you tell it to see them. You explicitly have to tell git to notice the edits in your files.
How can you see what is in your Staging Area? Run the command git status like before. It will look something like the image below.
The Local Repository:
The Local Repository is everything in your .git directory. Mainly what you will see in your Local Repository are all of your checkpoints or commits. It is the area that saves everything (so don’t delete it). That’s it.
How do you add items from your Staging Area to your Local Repository? The git command git commit takes all changes in the Staging Area, wraps them together and puts them in your Local Repository. A commit is simply a checkpoint telling git to track all changes that have occurred up to this point using our last commit as a comparison. After committing, your Staging Area will be empty.
How can you see what is in your Local Repository? There are a few commands that you can do that show different things.
git ls-tree --full-tree -r HEAD
This command shows all files within your git repo that it’s tracking. I don’t use this one that much because I rarely need to see every file that is being tracked by git.
git log
I use this command a lot more as it brings up a log of all previous checkpoints in my repository. If I want to see more information about a specific commit, then I run the command git show #commit# to see what was changed at that specific checkpoint.
결국 정리하면 워킹 트리는 그냥 진짜 내가 작업중인 부분이고, 스테이징으로 올리면 깃이 스테이징에 올라온걸 트랙킹함. 그리고 로컬은 내가 커밋해서 저장하는 상태임, 히스토리,로그로 생성됨.
'기타 > git 사용' 카테고리의 다른 글
<git사용법> 깃 원격-포크-로컬 사이의 관계 (0) | 2020.05.15 |
---|---|
<git사용> 소스트리에서 git 로컬과 리모트 차이 그리고 서로 업데이트. (0) | 2020.05.14 |
<git사용> 커밋 메시지 작성법 (0) | 2020.05.13 |
<git 사용법> git reset -hard,soft,mixed (0) | 2020.04.28 |
<git 사용법> git에서 fetch , pull 차이 (0) | 2020.04.27 |