깃은 공통으로 관리는 프로그램 소스코드 관리하기 위한 플랫폼입니다
카카오톡 예시
버전별로 하나하나 깃허브가 관리해서 사용하는 버전에서 오류가 발생하면 이전 버전의 코드를 가져오는 것이 가능
git 검색-> download 들어가서 다운로드 -> standalone Installer ->64bit ->다운받아서 설치
git bash실행
구글에 Git 최초 설정 검색
course에 'git'폴더 생성->우클릭->git bash here
{$ git config --
--는 옵션을 의미}
bash 실행하고
$ git config --global user.name "Youngjae-Joo" ->이름으로
$ git config --global user.email "joo0jae@gmail.com"->본인이 가입한 깃허브의 이메일 주소
$ git config --list 실행하면 이름과 이메일이 보임. 그 상태로 방향키 아래로 내리면 end가 나온다
: q를 하면 다시 생성 가능
+)창이 크면 그냥 나가질수도 있다. 창은 조금 작게
깃 설치 후 최초 설정
Git은 커밋 할 때마다, 현재 운영체제에 설정 된 아래 정보를 사용한다.
혼자 사용하는 컴퓨터라면 한번만 선언하면 되지만,
매번 다른 환경이라면 사용자 정보를 설정한다.
$ git config --global user.name "본인이름영어로"
$ git config --global user.email 본인이메일
사용자 정보 설정 확인
$ git config -list
깃 허브
버전이 되기까지 거쳐가는 세 개의 로컬 공간
1.working directory-작업공간. 모든 변경사항들이 담기는 공간
2.staging area -변경 사항들 중 후보들이 올라가는 공간.
3.repository-실제 저장소
git init :깃 시작. 숨김폴더 생김
git status :현재 상태
git add 파일명
git rm
git add
git commit -m"메시지"
git log
git add를 하면 working directory에서 staging area로 올라감
git commit을 하면 repository로.
git폴더에 myproject 폴더 생성->여기서 다시 bash 실행
->폴더 안에 ex01메모장파일 생성. 내용은 아무거나
->bash에서 git status
ex01.txt가 빨간색으로 뜨는데, 아직 staging area에 올라가지 않았다는 뜻
-> git add ex01.txt를 하고 git status를 하면 초록색으로 바뀜. 올라갔다는 뜻
이때 git rm --cached ex01.txt를 하면 unstage가 된다
->git commit을 하면 bash의 staging area에 올라가 있는 파일만 가능하다
$ git commit -m "메시지내용"
->잘 올라갔는지 확인하기 위해선 git log
-> 올라갔으면 staging area는 다 저장소로 들어감. 그래서 working tree는 clean한 상태
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject
$ git init
Initialized empty Git repository in C:/Users/user/Desktop/course/git/myproject/.git/
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
ex01.txt
nothing added to commit but untracked files present (use "git add" to track)
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git add ex01.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: ex01.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git commit -m "20221208주 영 재 -첫번째커밋"
[master (root-commit) cd8dd8b] 20221208주 영 재 -첫번째커밋
1 file changed, 1 insertion(+)
create mode 100644 ex01.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git log
commit cd8dd8bb431dff219228c4a2984a819f85704e95 (HEAD -> master)
Author: Youngjae-Joo <joo0jae@gmail.com>
Date: Thu Dec 8 12:11:20 2022 +0900
20221208주 영 재 -첫번째커밋
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
nothing to commit, working tree clean
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
ex02.txt
ex03.txt
nothing added to commit but untracked files present (use "git add" to track)
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git add ex02.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: ex02.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
ex03.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git rm --cached ex02.txt
rm 'ex02.txt'
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
ex02.txt
ex03.txt
nothing added to commit but untracked files present (use "git add" to track)
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$
git add .을 하면 모든 파일을 staging area에 올린다는 뜻
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git add .
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: ex02.txt
new file: ex03.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$ git commit -m "두번째커밋"
[master 742aa78] 두번째커밋
2 files changed, 2 insertions(+)
create mode 100644 ex02.txt
create mode 100644 ex03.txt
user@DESKTOP-GV1JMRN MINGW64 ~/Desktop/course/git/myproject (master)
$
파일을 수정, 변경하고 git status를 하면 바뀐 파일이 modified로 바뀜.
그럼 다시 처음부터 올려줘야 함
git add, git commit -m""
조심해야함
git commit –am “메시지” : 추가와 커밋 을 동시에 한다
깃을 원격저장소에 올리는 작업
->git에 repository 생성
!!!!!하나의 프로젝트는 하나의 repository로 해야 함!!!!!!
README file :프로젝트에 대한 설명을 해주는 파일. 나중에 만들 수도 있다
gitignore :깃에 올라갈 때 제거할 파일을 넣을 수 있는 파일. .ignore로 하면 된다
git remote add origin 본인깃계정 :원격저장소를 추가한다
git push origin master :원격저장소에 저장한다
->경로 복사는 shift insert 또는 우클릭 paste
※오류시
기존에 해당 컴퓨터에서 다른 깃 계정을 사용하던 경우 에러가 발생함
윈도우 검색-windows 자격 증명->깃관련 자격증명 관리를 삭제한다
remote add origin을 한번만 해 주면 다음부터 commit하고 나서는 push origin master만 해주면 된다
'Git' 카테고리의 다른 글
221208 Git 명령어(local repository) (0) | 2022.12.08 |
---|---|
221026 Github 사용 (0) | 2022.10.26 |