728x90

 

git diff 코드 정리

git diff
git diff HEAD
git diff --staged
git diff [filename]
git diff [branchname1]..[branchname2]

 

 

 

git diff란?

commit이나 branch 사이에 다른 점

파일(Working Directory)와 Repository 사이에 다른 점을 보여주는 명령어

출처 : [Git] git diff 한 번에 정리하기 — Dev World (kotlinworld.com)

 

 

git diff와 git diff HEAD 차이

1) git diff

Working Directory와 Staging Area 사이의 차이를 확인하기 위해 사용

  • caution : git add로 Staging Area로 넘어갔으면 git diff에서 보여주지 않음

 

2) git diff HEAD

Working Directory와 Staging Area 의 변경사항 모두를 Repository의 HEAD 커밋과 비교함

Staging Area에 올라간 내용은 물론 현재 작업 중인 내용(Working Directory) 모두 Repository의 HEAD와 비교됨

  • Staging Area로 올라가 안보인 변경사항은 git diff HEAD로 보인다

출처 : [Git] git diff 한 번에 정리하기 — Dev World (kotlinworld.com)

 

 

git diff 메세지 내용

상황 : test.txt에 원래 데이터 123에서 456을 추가함

  • 1번 ---a : 변경 전 파일 지칭명
  • 2번 +++b : 변경 후 파일 지칭명
  • 3번 test.text : 변경 전 파일명
  • 4번 test.text : 변경 후 파일명
  • 5번 - : 변경 전 파일 지칭
  • 6번 1,3 : 코드 1번 line 기준으로 3번 line까지 변경됐다는 의미
  • 7번 + : 변경 후 파일 지칭
  • 8번 1,6 : 코드 1번 line 기준으로 6번 line까지 변경됐다는 의미
  • 9번 123 : 변경 전 파일의 코드 1-3번라인의 내용
  • 10번 +4 +5 + 6 : 변경 전 파일(-) 1-3번 라인 뒤에 변경 후, 파일(+) 4-6번라인이 추가됐다는 의미

 

 

 

 

 

 

 

git diff --staged

git diff --staged는 Staging Area와 Repository HEAD 커밋 사이의 변경사항 확인을 위해 사용

커밋 전 사용되는 명령어로 가장 많이 씀

Staging Area에 올라간 변경사항만 Repository의 HEAD 커밋과 비교되며, 현재 작업 중인 Working Directory에서 git add되지 않은 변경된 사항은 반영x

※ git diff --staged와 git diff --cached 같다

출처 : [Git] git diff 한 번에 정리하기 — Dev World (kotlinworld.com)

 

 

git diff [option] [filename]

git add 파일명처럼 특정 파일에 대한 변경사항만 확인할 때 사용

git diff [option] [filename]

 

 

git diff [branch1]..[branch2]

브랜치 간 변경사항 확인

git diff [branch1]..[branch2] 

 

 

 

※ 그냥 git add 하면 git diff가 안나오는데 왜그럴까?

git diff는 Working Directory와 Staging Area 사이의 차이를 보여주는데,

git add를 통해 Staging Area에 변경 사항이 올라가버렸기 때문

 

 

 

 

참고자료

https://kotlinworld.com/278#git%--diff�%--%--%--git%--diff%--HEAD%--�%A-�%--�%-D%B-�%-A%A-�%--%-C%--�%B-%--�%B-�%--�%--��%--�%--�%--%--�%-D%B-

 

 

728x90
반응형
728x90

 

 

어제 하루 종일 git 연습했다. merge conflict 나면 당황하지 않고 스무쓰하게 처리할 수 있게 되는 게 

목표여서 조금이라도 숙달되기 위해 계속 연습했다.

오늘 코딩 공부하면서 지난 번 노트북에서 작업했던 내용 커밋을 까먹었는지 마침 리모트랑 충돌이 나서

처음으로 길이가 좀 있는 코드의 merge conflict를 혼자서 해결했다. 노트북에 코드를 stash하고 원격에 있는 걸 pull 해온 후, stash pop으로 다시 불러와 이 과정에서 merge conflict를 했는데

터미널 안에서 vi 파일명으로 코드 수정 가능한 것도 알았고, 그래서 좀 만져보다가 소스트리로도 해결해보고 싶어서

소스트리에서 충돌난 파일을 인텔리제이로 연결해서 이걸로 수정을 마치고 커밋 푸쉬했다. 처음으로 머지 컨플릭트를 해결해서 한결 성장한 기분이 든다.

좀 더 연습하고 익숙해지면 커밋을 압축하는 squash에 대해 알아봐야겠다. 어제랑 엊그제도 조금 해봤는데 혼란이 와서 일단 머지만 연습했다.

 

이제 정처기 공부하러!

 

 

728x90
반응형
728x90

 

로컬에 내용들이 다 날라가고 리모트에 있는 내용들을 다 가져오는 것이므로 로컬에서의 데이터가 유실 될 수 있으니 괜찮은 경우에만 사용할 것!

git fetch --all
git reset --hard origin/[브랜치명]
git pull origin [브랜치명]

 

개념

1.git fetch --all

conflict가 발생하면, fetch로 remote(깃허브) 저장소에서 이전 파일들을 fetch해와 local로 저장해둔다

 

2.git reset --hard origin/[브랜치명]

local에서는 reset hard로 컨플릭트 발생 전 상태로 되돌림

 

3.git pull origin [브랜치명]

1번에서 자료를 받아두고 2번에서 클린하게 해두고 3번에서 다시 받아오는 형식

 

ex)

git fetch --all
git reset --hard origin/main
git pull origin main

 

728x90
반응형
728x90

에러메시지

fatal: refusing to merge unrelated histories

 

상황

신규 repository에 새로 push 할려는 상황

근데 git local과 연결하고 push하기 전에 github에서 먼저 read.me를 만들어두고 전날 커밋해둠. 리드미를 지우면 해결되지만 전 날 잔디를 유지하고 싶어서 방법을 찾는 중

 

원인

에러 메세지 의미 : commit 히스토리가 서로 관련이 없다는 뜻

즉, 서로 관련성이 없기 때문에 merge할 수 없다는 것

 

github에서 새 repository를 생성하면서 만든 readme.md 파일때문인데

Git의 작동방식은 로컬 저장소의 commit 목록과 원격 저장소의 commit 목록을 비교한 후 원격 저장소의 마지막 commit id와 동일한 commit id를 가진 로컬 저장소의 commit 시점을 찾아낸 뒤, 원격 저장소의 마지막 커밋과 연결하기 때문

원격 저장소의 첫번째 commit이자 마지막 commit인 readme를 추가하는 commit이 원격 저장소에는 존재하지 않고, 따라서 현 상태에서는 둘을 연결할 수 없다.

 

해결

방법1

repository를 삭제하고 다시 만든다. (readme.md 파일을 없애고 다시 저장소를 만든다.)

 

방법2

git pull origin 브런치명 --allow-unrelated-histories

git에서는 서로 관련 두 프로젝트를 병합할 때 기본적으로 거부하는데, 이를 허용하는 명령어

 

방법3

강제로 합병하는 방법

주의! 기존 커밋했던 코드 및 파일이 유실될 수 있음

git push -u origin +master
git push origin master -f

 

 

참고자료(Reference)

https://jobc.tistory.com/177

https://seolahchloe.tistory.com/entry/Git-오류해결-Updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-its-remote

728x90
반응형
728x90

 

1. 브랜치(branch) 생성 : branch

$ git branch 브랜치명

예시

$ git branch test1

2.브랜치(branch) 변경 : checkout

$ git checkout 브랜치명

 

 ※ 브랜치(branch) 생성 및 변경 한번에

-b 추가

$ git checkout **-b** 브랜치명

3.Merge

$ git **merge** <commit>

 

4. 브랜치(branch) 삭제 : branch -d

$ git **branch -d** 브랜치명

 

 

 

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository
$ git init
Initialized empty Git repository in D:/Git_Repository/.git/

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -b test1
error: unknown switch `b'
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]
   or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]
   or: git branch [<options>] [-l] [<pattern>...]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track[=(direct|inherit)]
                          set branch tracking configuration
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display object names

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    -l, --list            list branch names
    --show-current        show current branch name
    --create-reflog       create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --recurse-submodules  recurse through submodules
    --format <format>     format to use for the output


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <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
   restore   Restore working tree files
   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
   diff      Show changes between commits, commit and working tree, etc
   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
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   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.
See 'git help git' for an overview of the system.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch master
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test1
error: pathspec 'test1' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch a
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ ls -al
total 20
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:18 ./
drwxr-xr-x 1 csy62 197609 0 Jul 14 08:20 ../
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:17 .git/
-rw-r--r-- 1 csy62 197609 0 Jul 31 03:18 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch 'test'
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        a.txt

nothing added to commit but untracked files present (use "git add" to track)

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git add a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
[master (root-commit) 0505a6a] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -m test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test
* test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git branch -m test0

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch
* test0
  test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch -d test2
Deleted branch test2 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
On branch test2
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test2
error: Cannot delete branch 'test2' checked out at 'D:/Git_Repository'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout -b test3
Switched to a new branch 'test3'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test3)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test3
Deleted branch test3 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test2
Already on 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 76d033f] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test3
merge: test3 - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge master
merge: master - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git show
commit 76d033f78943e8d9856b60b2c323dd80098a23fe (HEAD -> test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:30:07 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git status
On branch test2
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 c0f83ba] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge
fatal: No remote for the current branch.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git test1
git: 'test1' is not a git command. See 'git --help'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating 0505a6a..c0f83ba
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 "a - \353\263\265\354\202\254\353\263\270.txt"                            | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git status
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git show
commit c0f83baab10cff7a90120db6ba4f3975c3e743f7 (HEAD -> test1, test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:32:43 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 2
[test2 d4529f8] 2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git commit -m 3
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test3
error: pathspec 'test3' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
error: The branch 'test2' is not fully merged.
If you are sure you want to delete it, run 'git branch -D test2'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating c0f83ba..d4529f8
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
Deleted branch test2 (was d4529f8).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
728x90
반응형
728x90

 

 

remote 연결, 조회, 연결해제

 

remote 연결

원격저장소(remote) 연결하기

git remote add <name> <url>

ex)

git remote add origin [<https://github.com/neverGiveUpppppp/kh-workspace.git>](<https://github.com/neverGiveUpppppp/kh-workspace.git>)

 

 

remote 목록보기

연결된 원격저장소(remote) 목록보기

git remote -v 

 

현재 로컬에 연결된 remote 목록    

 

remote 삭제

해당 원격저장소(remote) 삭제

git remote remove 리모트명

 

728x90
반응형
728x90

 

지난 번 했던 

브랜치 생성

브랜치 변경

브랜치 생성 및 변경 한번에 하기

브랜치 삭제

add, commit, push 하기

 

 

 

728x90
반응형
728x90

 

깃을 처음 세팅하면서 유저 이름(name),이메일(email)을 등록하게 되는데

이때 오타가 있거나 등록한게 마음에 안들거나 한다면 변경하고 싶을 것이다. 나처럼ㅋㅋ

 

이렇게 name까지만 치면 현재 등록된 이름이 나온다

이메일도 마찬가지

 

변경하는 방법은 저 세팅 코드에서 name이나 email 다음 변경하기를 원하는 이름과 이메일주소를 넣으면 된다

$ git config --global user.name 변경할이름
$ git config --global user.email 변경할이메일주소

 

 

 

728x90
반응형
728x90

 

깃허브에서 디폴트 브랜치명이 master라 main으로 바꿨다.

예전에는 master라고 다들 썼는데 master slave라는 표현이 인권 문제 쪽 이슈 때문에

표현 자체가 좀 그렇다고 해서 깃허브에서도 main으로 쓸 것을 권유한다고 들었다. 그래서 겸사겸사 깃허브에서 브랜치명을 바꿨는데 깃배쉬에서는 여전히 master로 되어있어서 새로운 브랜치명으로 master로 만들어져서 들어가는 것 같았다.

그래서 깃배쉬에서의 master를 main으로 바꾸었다

 

1.브랜치 목록 확인

git branch

 

아래처럼 전체 브랜치 리스트를 볼 수 있다

 

2.브랜치 이름 변경

git branch -m 현재브랜치명 변경될이름의브랜치명

 

 

 

 

 

 

728x90
반응형
728x90

 

Merge하다  해당 메시지와 함께 아래의 화면이 나올 경우

Please enter a commit message to explain why this merge is necessary,

especially if it merges an updated upstream into a topic branch.

일단 이는 깃 에러 메시지가 아니라고 한다. 깃이 사용하는 디폴트값의 에디터라고 하며

해결방법은

  1. press "i" (i for insert)
  2. write your merge message
  3. press "esc" (escape)
  4. write ":wq" (write & quit)

이렇게 하여 빠져나왔다

 

출처

https://stackoverflow.com/questions/19085807/please-enter-a-commit-message-to-explain-why-this-merge-is-necessary-especially

 

728x90
반응형

+ Recent posts