본문 바로가기

카테고리 없음

git github (windows)

 

 

https://gitforwindows.org/

 

Git for Windows

Git for Windows focuses on offering a lightweight, native set of tools that bring the full feature set of the Git SCM to Windows while providing appropriate user interfaces for experienced Git users and novices alike. Git BASH Git for Windows provides a BA

gitforwindows.org

 

 

나는 걍 default로 설치함

 

 

git version 확인

 

git --version

 

git user email 및 name 확인

 git config --global user.email "piaocanyi1997@gmail.com"
 
 git config --global user.name "canyi"

 

git 초기화

git init

경로를 따라 확인

Initialized empty Git repository in D:/git/gittest/.git/

 

git할 변경된  파일 스테이징

 git add test.txt

 

commit할 파일 코멘트 추가

git commit -m '관련내용메세지'
[master (root-commit) 89baa62] 관련내용메세지
 1 file changed, 2 insertions(+)
 create mode 100644 test.txt

 

 

git으로 변경된 모든 파일을 전부 스테이징 하고싶다.

git add .

 

git 상태 확인

git status
On branch master
nothing to commit, working tree clean

 

 

git log확인

git log
Author: canyi <piaocanyi1997@gmail.com>
Date:   Fri Nov 25 14:33:36 2022 +0900

    관련내용메세지

 

 

txt 파일 수정

 

 

status를 확인해보니 변경됐다고 add하라고  뜸

 

 

git add하고 status  확인해보니 commit하라고 뜸 

 

 

commit하고 log 확인 

 

 

 

커밋 기록 확인완료

 

 

 

메모장에 값을 변경함

 

 

 

diff 사용법

(1) git diff로 변경된 값 확인 (전 commit된 버전과 방금 변경된 부분 확인)

git diff

 

 

(2)git log 를 사용해서  commit번호를 확인해서 git diff로 번전 다른점 확인

 

git log

결과

commit 449703eb766124ba5d351d7c7c20ba769610ef8b (HEAD -> master)
Author: canyi <piaocanyi1997@gmail.com>
Date:   Fri Nov 25 14:43:43 2022 +0900

    두번째 커밋

commit 89baa626996c8e931228782439c7249e24a17f9d
Author: canyi <piaocanyi1997@gmail.com>
Date:   Fri Nov 25 14:33:36 2022 +0900

    관련내용메세지

 

두 버전 다른점 확인

git diff 449703eb766124ba5d351d7c7c20ba769610ef8b 89baa626996c8e931228782439c7249e24a17f9d

 

결과

diff --git a/test.txt b/test.txt
index 9c2fead..5237ed4 100644
--- a/test.txt
+++ b/test.txt
@@ -1,4 +1,2 @@
 오늘의 할일
-1. 머리 감기
-2. 훠궈 먹기
-3. 게임하기
\ No newline at end of file
+1. 머리 감기
\ No newline at end of file

 

 

 

 

git   branch 사용법  (git branch 브랜치이름)

git branch price

 

새로 생성한  price 브랜치로 이동 (git switch 브랜치이름)

 

git switch price

결과

Switched to branch 'price'
M       test.txt

 

 

mother.txt 라는 txt 추가

 

add 및 commit

 

master 브런치로 이동

git switch master

 

내사 새로 만든 mother.txt가 없어

 

 

price 브런치로 이동해보니 또 생김 (mother.txt 는 price 브런치에서 만들었기 때문이다.)

git switch price

 

 

그럼 master  브런치에서  price에 있는 내용도 같이 보고 싶다.

 

그러면  git merge 가져오고 싶은 브런치이름

 

현재는 master 브런치

git merge price

 

결과

성공적으로 합쳐짐!

 

 

 

 

 

 

git 컴플리트 충돌

 

PS D:\git\gittest> git status
On branch master
nothing to commit, working tree clean
PS D:\git\gittest> git commit -m "상궈"
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   mother.txt

no changes added to commit (use "git add" and/or "git commit -a")
PS D:\git\gittest> git add .
PS D:\git\gittest> git commit -m "상궈"
[master 533d0c3] 상궈
 1 file changed, 1 insertion(+), 1 deletion(-)
PS D:\git\gittest> git switch price 
Switched to branch 'price'
PS D:\git\gittest> git add .
PS D:\git\gittest> git commit -m "짬뽕"
[price 712a980] 짬뽕
 1 file changed, 1 insertion(+), 1 deletion(-)

 

현재  price 는짬뽕 ,  master는 상궈

 

price 브런치에 서 master 브런치 mergr함

git merge master
CONFLICT (content): Merge conflict in mother.txt
Automatic merge failed; fix conflicts and then commit the result.

충돌 발생

 

 

수동으로  수정해줌(저장)

 

 

 

git + github 연결

https://piaocanyi.tistory.com/351