티스토리 뷰

반응형

< Windows 환경으로 제작된 글입니다. >




안녕하세요. Base Of Coding입니다. 이번에 알아볼 git의 내용은, init과 status 명령어에 대해서 알아보도록 하겠습니다.


이전 글에서, 깃허브 회원가입과 git의 설치법이 자세히 나와있으니, 회원가입 및 설치를 안하신 분들은, 밑에 링크로 걸어놓을 글을 보고 회원가입 및 설치를 해주시고 이 글을 봐주시길 바랍니다.


2018/11/23 - [- 프로그래밍 정보 -/Git] - [ Git ] 1. GitHub 회원가입 및 Git Bash 설치방법


그럼 시작하겠습니다.





< 1. Git 사용하기 >

- git을 설치하셨다면, 아무런 위치에 폴더를 하나 생성해주시길 바랍니다. 저는 바탕화면에 baseofcoding이란 폴더를 하나 생성하겠습니다.

그리고나서, 해당 폴더를 오른쪽 마우스로 클릭하시게 되면, Git GUI Here과, Git Bash Here이 추가가 되어 있으실겁니다.


저는 Git Bash Here로 진행하도록 하겠습니다. Git Bash Here을 클릭해주세요.





< 2. git이라고 입력을 해보자 >

- Git Bash Here을 클릭하면, 명령 프롬프트와 같은 창이 뜰겁니다. 그 창에 git이라고 입력을 한 번 해보실까요?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
usage: git [--version] [--help] [-<path>] [-<name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-| --paginate | -| --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status
grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.


그럼 이러한 글들이 쭉 나올텐데요. git이란 명령어는 git에서 사용할 수 있는 모든 명령어들에 대한 정보 및 설명이 나와있습니다. 물론 영어로 되어있습니다.


자 이렇게, 명령어를 입력해서, git을 이용하여, github에 폴더에 있는 파일들을 업로드하는 방식을 할 예정입니다.


잘 따라와주세요.




< 3. git init? >

- git init은, 현재 디렉토리에 작업을 진행하겠다는 명령어입니다. 한 번 git init이라고 입력을 해보겠습니다.

1
Initialized empty Git repository in C:/Users/계정명/Desktop/baseofcoding/.git/


이런 글이 뜨면 성공입니다. git init을 추가한 뒤, 해당 폴더로 들어가보겠습니다. 



왜 폴더가 비어있는거지? 라고 생각하실 수 있는 분들도 계실거라고 생각합니다. 저 맨 뒤에 나오는 .git은 어딨어!! 라고 생각하실 수 있는데요. 해당 .git 폴더는 숨김 파일 항목으로 설정되어 있습니다.


저 .git 폴더안에 저희가 버전관리 할 정보들이 들어가기 때문에, 삭제를 못하게끔 막아놓았다고 생각하시면 될 것 같습니다. 버전관리가 필요없다고 생각하시면 그냥 해당 폴더를 지워주시면 된답니다.


숨김 파일 항목 해제를 하시면 .git 폴더를 보실 수가 있습니다.





< 4. 폴더에 txt 파일을 추가하고, git status라고 입력해보자. >

1. ls -al 입력

- ls -al은, 현재 디렉토리의 파일 목록을 보여주는 명령어 입니다. ls -al이라고 입력을 하고 엔터키를 누르시면, 해당 디렉토리의 파일 목록들이 나오는데 밑에와 같은 형식으로 나오시면 성공입니다.


1
2
3
4
total 12
drwxr-xr-1 계정명 197121 0 11월 24 16:14 ./
drwxr-xr-1 계정명 197121 0 11월 24 16:03 ../
drwxr-xr-1 계정명 197121 0 11월 24 16:14 .git/



2. txt 파일 생성 및 입력

1. vim test.txt 라는 명령어를 입력해주세요. 다음과 같은 화면이 나오시면 됩니다.



2. 입력을 하실 때에는 I키를 누르시고, 입력을 해주세요. 입력이 완료되셨다면, ESC 키를 클릭하시면 됩니다. 저는 test ing...이라고 입력을 해보도록 하겠습니다.



입력이 아주 잘 되었습니다.



3. vim 화면을 나갈 때에는 :wq를 입력해서 나갑니다. 



wq는, Write와 Quit를 의미합니다. 이렇게 입력하시고 엔터키를 눌러주신 후, 다시 ls -al을 입력 한번해보겠습니다.


1
2
3
4
5
6
$ ls -al
total 17
drwxr-xr-1 계정명 197121  0 11월 24 16:29 ./
drwxr-xr-1 계정명 197121  0 11월 24 16:03 ../
drwxr-xr-1 계정명 197121  0 11월 24 16:14 .git/
-rw-r--r-- 1 계정명 197121 12 11월 24 16:29 test.txt


test.txt 파일이 생성이 되었습니다!! 이제 git status 명령어를 입력해볼까요?



3. git status 입력

- git status라고 입력을 하게 되면, 밑에와 같은 글이 뜨게 됩니다. test.txt는 빨간색 글씨로 표시가 되어 있을거구요.

1
2
3
4
5
6
7
8
9
10
On branch master
 
No commits yet
 
Untracked files:
  (use "git add <file>..." to include in what will be committed)
 
        test.txt
 
nothing added to commit but untracked files present (use "git add" to track)


git status는, 현재 버전관리의 상태를 보여주는 명령어입니다. Untracked files로 빨간색 글씨가 되어있는 경우는, 추적되지 않은 파일 즉, 아직 git에 올릴 준비가 되지 않은 파일이란 표시입니다.



자 이렇게, 디렉토리에 .git 폴더와, 현재 폴더의 버전관리 상태를 보여주는 명령어들을 배워보았습니다. 다음은, 이제 git에 올릴 준비가 가능하게 할 git add라는 명령어와 github 닉네임과 아이디를 구성하는 방법을 알아보도록 하겠습니다.


지금까지 Base Of Coding이였습니다. 감사합니다.



< 간단한 요약 >

1. git init은, 현재 디렉토리에 작업을 진행하겠다는 명령어
2. git이란 명령어는, 내가 사용할 수 있는 git의 명령어들 및 설명에 대한 글이다.
3. ls -al은, 현재 디렉토리의 파일 목록을 보여주는 명령어이다.
4. git status는, 현재 버전관리의 상태를 보여주는 명령어이다.
5. vim으로 입력할 때에는 I키를 누르고 입력한 뒤, 입력이 완료되었다면, ESC키를 눌러 완료하고, :wq를 입력하여, vim창을 나가도록 하자.





- 이 글에 도움이 되셨다면, 공감(♡) 버튼과 댓글 부탁드리겠습니다. - 



< 공부 한 내용을 바탕으로 작성된 글 입니다. >




반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함