[공지] SMS114.CO.KR 바로가기
www.sms114.co.kr
👉 텔레그램 상담 바로가기

1 분 소요

git summary

1. git 최신 내용 로컬로 가져오기

git pull origin main --rebase

변경 사항을 다시 푸시하기

git push origin main

그래도 안 될 경우, 강제 푸시( – force 사용은 신중하게 해야 함.)

git push origin main --force

이 오류는 GitHub 원격 저장소(GitHub)에 있는 내용과 내 로컬 저장소가 동기화되지 않아서 발생하는 문제 해결

오류 분석: “Updates were rejected because the remote contains work that you do not have locally”

$ git push -u origin main
To https://github.com/sms114/0bsidian-public-repository-2025-01-31.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/sms114/0bsidian-public-repository-2025-01-31.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details

위 경우,

git pull origin main --rebase

--rebase 옵션은 내 로컬 변경 사항을 최신 원격 변경 사항 뒤에 추가하는 방식이라 충돌을 최소화할 수 있어.

GitHub 원격 저장소 추가

  1. 먼저 git 을 사용할 폴더로 이동

    cd "C:\Tool\firstVault"
    
  2. git status

  3. git init

  4. git remote add origin https://github.com/innolifes22/obsidian_private_Note_20250131.git

    private repository 에 접근하고자 할 경우….

    git remote add origin https://innolifes22:github_pat_11A3EKVYY0kwzxxxxxxxr6gfjuFL2_jN6UZJDj6rH9Vpenlj8VF7GHusDCHVzs1FcGmcNi9orYSMYL5HPbY7LzdLd@github.com/innolifes22/obsidian_private_Note_20250131.git

    git remote add origin https://github.com/innolifes22/obsidian_private_Note_20250131.git 위에서 잘 못 셋팅된 것 올바른 설정은?

    git remote set-url origin https://github.com/innolifes22/obsidian_private_Note_20250131.git

  5. git remote -v // 정상적으로 연결되었는지 확인
    origin  https://github.com/innolifes22/0bsidian-public-repository-2025-01-31.git (fetch)
    origin  https://github.com/innolifes22/0bsidian-public-repository-2025-01-31.git (push)
    
  6. GitHub에 처음으로 파일 업로드
    git add .
    git commit -m "Initial commit"
    git branch -M main
    git push -u origin main
    
  7. GitHub에서 변경 사항을 로컬로 가져오기 (pull) $ git pull origin main

  8. 이후 변경된 파일을 GitHub에 업로드하는 방법
    git add .
    git commit -m "Updated files"
    git push origin main
    

    기존 GitHub 인증 정보 삭제하려면?

1. Git Credential Manager에서 기존 인증 정보 삭제

① 저장된 GitHub 인증 정보 삭제

git credential reject https://github.com

이후 다시 git push를 시도하면 GitHub 로그인 정보를 다시 입력하라고 할 거야.


2. Windows 자격 증명 관리자에서 삭제 (GUI 방식)

Git이 Windows의 자격 증명 관리자에 인증 정보를 저장하는 경우도 있어. 이걸 직접 삭제하는 방법이야.

Windows에서 GitHub 인증 정보 삭제 방법

  1. Windows 검색창에 자격 증명 관리자 입력 후 실행
  2. Windows 자격 증명 탭 선택
  3. GitHub 관련 항목 (git:https://github.com) 찾기
  4. 해당 항목을 삭제

태그:

카테고리:

업데이트:

댓글남기기