git add, git status, git commit, git log
git add, git status, git commit, git log
git add: staging 영역으로 보내기
git add 명령어는 working directory에 있는 파일을 staging area로 보내는 역할을 수행합니다.
$git add <파일명>
한꺼번에 여러 파일을 staging area로 보내고 싶다면 현재 폴더를 대상으로 git add를 수행할 수 있습니다.
$git add .
예제) deepmal.txt 생성 하고 git add 수행
1. staging 영역으로 보낼 파일을 생성합니다.
ubuntu에서 nano 명령어를 통해 deepmal.txt를 생성하고, 내용을 작성합니다.
$nano deepmal.txt
deepmal.txt에 "Hello World!"를 입력 한 뒤, Ctrl + X 를 누릅니다.
Save 할 것인지 질문에 Y를 입력합니다.
파일명에 deepmal.txt가 입력된 것을 확인 하고 엔터를 입력합니다.
2. deepmal.txt 생성 완료 및 내용확인
deepmal.txt 파일이 생성되었는지 확인하기 위하여, ubuntu에서 ls 명령어를 실행합니다.
cat 명령어를 통해 deepmal.txt의 내용을 확인할 수 있습니다.
$ls -l
$cat deepmal.txt
3. git add 명령어를 통해 staging area로 보내기.
git add 명령어를 통해 deepmal.txt를 staging area로 보냅니다.
$git add deepmal.txt
git status: staging 상태 확인
git status 명령어를 통해 staging area의 상태를 확인할 수 있습니다.
$git status
예제) deepmal.txt가 staging area에 있는지 확인
$git status
git add를 수행한 deepmal.txt가 staging area에서 new file로 인식되고 있음을 확인 할 수 있습니다.
git commit: git 저장소 반영
git commit은 .git 저장소(repository) 내에 staging 파일을 저장하는 역할을 수행합니다.
$git commit -m "message"
staging area에 있는 파일들을 repository에 반영합니다. 메시지는 생략가능 합니다.
예제) git commit 수행하여, staging area에 있는 내용을 repository에 반영하기
git commit 명령어를 수행하겠습니다. 메시지는 "commit 1"입니다.
$git commit -m "commit 1"
staging area에 있던 deepmal.txt가 repository로 반영되었습니다.
git status 명령어를 통해 staging area를 확인합니다.
$git status
deepmal.txt가 staging area에 있었는데 git commit 이후, staging area가 비어있음을 확인합니다.(nothing to commit)
git log: .git repository에 존재하는 history 확인
git log 명렁어는 repository에 반영 내역을 확인할 수 있습니다.
$git log
예제) git log 실행하여 repository history 확인
$git log
ssali<deepmal@gmail.com>라는 Author가 방금 commit을 수행하였음을(메시지: commit 1) 알 수 있습니다.
같이 보시면 좋아요.
2021.04.30 - [Linux] - ubuntu 명령어 모음 1
ubuntu 명령어 모음 1
ubuntu 명령어 모음 1 whoami: 사용자 ID 확인 whoami 명령어는 로그인한 사용자의 ID를 알려줍니다. $whoami 다음과 같이 ubuntu에서 whoami 명령어를 통해 사용자의 ID를 확인할 수 있습니다. whoami 명령..
deepmal.tistory.com
2021.05.03 - [Linux] - ubuntu 명령어 모음 2
ubuntu 명령어 모음 2
ubuntu 명령어 모음 2 tree: 디렉토리 구조를 확인 tree 명령어는 ubuntu에서 디렉토리 구조를 출력합니다. $tree tree 명령어가 작동하지 않는다면, 다음 명령어를 통해 설치합니다. $sudo apt install tree..
deepmal.tistory.com
포스팅 내용이 도움이 되었나요? 공감과 댓글은 큰 힘이 됩니다!