-
Ch3.Commiting your changesRay Wenderlich/Mastering Git 2021. 7. 29. 02:11

// 간단한 것들 git status git diff // working area를 비교함, stage된 변화는 알 수 없음 git diff --staged // stage된 변화를 알 수 있음 git add filepath git add .Git log
git log // 커밋 메시지만 보여줌 git log -p // 커밋 diff까지 보여줌 // Space bar로 pagination가능, q로 종료 가능디렉터리를 만들었는데 Nothing to commit?
// 디렉터리를 만들었는데, nothing to commit?? mkdir tutorials ~/MasteringGit/ideas $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree cleanGit이 레포지터리의 Working tree를 인식하는 방법
Git은 Files에만 관심이 있고, Directory에는 관심이 없다. Git은 File을 "Git이 추적할 수 있도록 가리키는 문자열"으로 인식한다.
그 결과 Git은 쉽고 빠르게 Directory와 File system을 Clone할 수 있게 된다.
위 예제에서 Git이 Directory의 생성을 알아채도록 하는 방법은 Directory안에 파일을 하나 넣어 주는 것이다.
근데.. 아무것도 넣기 싫은 Directory일 수도 있잖아?
그렇다면 Placeholder파일을 사용해보자.
cd tutorials touch .keep ls -a ~/MasteringGit/ideas/tutorials $ ls -a . .. .keepcd .. ~/MasteringGit/ideas $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Untracked files: (use "git add <file>..." to include in what will be committed) tutorials/ nothing added to commit but untracked files present (use "git add" to track)git add tutorials/*50-72 Rule
유명한 커밋 메시지 작성 룰
메시지의 첫 번째 라인은 50자 이내
그 다음은 Blank line을 넣고
세 번째 라인부터는 72자 이내
https://meetup.toast.com/posts/106
Key points
- git add <filename> lets you add changes from your working tree to the staging area.
- git add . adds all changes in the current directory and its subdirectories.
- git add <directoryname>/* lets you add all changes in a specified directory.
- git diff shows you the difference between your working tree and the staging area.
- git diff --staged shows you the difference between your staging area and the last commit to the repository.
- git commit commits all changes in the staging area and opens Vim so you can add a commit message.
- git commit -m "<your message here>" commits your staged changes and includes a message without having to go through Vim.
- git log shows you the basic commit history of your repository.
- git log -p shows the commit history of your repository with the corresponding diffs.
'Ray Wenderlich > Mastering Git' 카테고리의 다른 글
Ch8. Syncing With a Remote (0) 2021.08.21 Ch7. Branching (0) 2021.08.06 Ch6. Git Log & History (0) 2021.08.05 Ch5. Ignoring Files in Git (0) 2021.08.05 Ch4. The Staging Area (0) 2021.07.29