programing

GitHub 리포지토리에서 변경한 내용으로 로컬 리포지토리 업데이트

muds 2023. 4. 26. 23:48
반응형

GitHub 리포지토리에서 변경한 내용으로 로컬 리포지토리 업데이트

GitHub에서 프로젝트를 로컬로 확인했는데, 원격 저장소가 변경되었습니다.로컬 복사본을 최신 변경사항으로 업데이트하는 올바른 명령은 무엇입니까?

아마도:

was: git pull origin 마스터

now: git pull origin 메인

이것은 모든 기본 repo에 대해 작동해야 합니다.

git pull origin master

기본 분기가 다음과 다른 경우master분기 이름을 지정해야 합니다.

git pull origin my_default_branch_name
git fetch [remotename]

그러나 변경사항을 로컬 분기에 병합해야 합니다.만약 당신이 Github의 원격 지점을 추적하는 지점에 있다면,

git pull

먼저 가져오기를 수행한 다음 추적된 분기에서 병합합니다.

이 질문은 매우 일반적이며 몇 가지 가정을 통해 간단히 설명하겠습니다.업데이트를 원하는 것으로 가정합니다.master분점.

로컬에서 변경한 내용이 없는 경우git pull새로운 커밋을 다운로드하여 추가합니다.master.

git pull origin master

변경한 후 새 병합 커밋을 추가하지 않으려면 다음을 사용합니다.git pull --rebase.

git pull --rebase origin master

git pull --rebase변경하지 않은 경우에도 작동하며 아마도 최선의 선택일 것입니다.

이미 설정된 오리진 마스터의 경우 아래 명령을 사용하면 됩니다.

git pull "https://github.com/yourUserName/yourRepo.git"

분기 체크아웃 및 마스터에서 변경사항 가져오기를 위한 워크플로우 완료

모든 원격 분기 풀

git pull -- 모두

지금 모든 분기 나열

git branch -a

지점 다운로드

git checkout -b<feature branch name copied from list of branches above>

현재 분기를 표시합니다.표시해야 함<feature branch>그 앞에 *와 함께

깃 가지

마스터 지점에서 현재 지점으로 체크아웃 변경 사항

git 풀 오리진 마스터

또는 다른 항목을 확인합니다.<feature branch>현재 지점으로.

git pull 기원<feature-branch>

기본 분기에서 풀하려면 새 리포지토리에서 다음 명령을 사용해야 합니다.

git pull origin main

Github은 2020년에 기본 브랜치의 명명 규칙을 마스터에서 메인으로 변경했습니다.https://github.com/github/renaming

이를 통해 Gitlab, Github 등과 같은 원격 저장소에 있는 업데이트된 저장소로 로컬 저장소를 업데이트할 수 있습니다.

git pull origin master

Git Clone 이후에 원격 분기를 가져오려면

git fetch --all

그런 다음 원하는 지점으로 체크아웃합니다.

git checkout the-branch-you-need

git pull origin mastergithub 변경, 로컬 저장소에서 적용

NB: 정상 작동 중

git에 대한 모든 것: https://gist.github.com/subrotoice/b27f7d20617bb3da04827a223faf6450

Complete Documentation
googel>>Install Git
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git // Type "git" to check it work or not?

#Basic Windows command like cd
cd\  = back to root directory c drive does not metter where its current postion 
cd .. = One step back
cd /d D: = C Drive to D drive
dir or ls(LS)  = List all file and folder of current directory. "ls" is more clear to read
mkdir mynewfolder = Create New Folder
cd "folderName" = To enter Folder for doing some task
cls = Clear Screen

#Upload A full new project (Make sure no file there even readme.md to avoid error)--Working==========
git config --global user.name "subrotoice"
git config --global user.email "subroto.iu@gmail.com"

git init    // Basically 3 steps, 1. add, 2. Commit, 3. Push
git add .   // Add to local repositories
git commit -m "first commit"  // Commit to local repositories
git remote add origin https://github.com/subrotoice/ccn.git  // ("origin Userdifine", origin=url.git, variable e value assign korar moto)
git push -u origin master  // push,  origin user define name like variable contain url. (master default brunch name, you can create brunch like, https://prnt.sc/26pq9x2

#master(default),  If you want to create other brunch not master(default), here brunch name is "main", Userdefine Name
git branch -M main // Create new branch main
git remote add origin https://github.com/subrotoice/33sfdf.git  // origin(any name) is variable name contain url, age url assing thakle ei line dorkar nai
git push -u origin main

git branch // Show current branch
git checkout master // Switched to branch 'master'

#Work on existing Project----------------
First you have to download project otherwise it will not work
git clone https://github.com/Tilotiti/jQuery-LightBox-Responsive.git   // Pull
cd folder_name // Need to change to inside folder
git add . For all new file and folder (git add file_names.exten  it is for single file)
git status  // to check the status of git files [optional]
git commit -m "committed message" For asingle file(git commit -m "committed message" file_names.exten)
git push -u origin master
git pull origin master // Change in github, it take effect in local reprository. 'Synchronization'

# Clone a Specic Brunch, in stade of main brunch master
git clone --branch <branchname> <remote-repo-url>
git clone -b <branchname> <remote-repo-url>
git clone -b main9 https://github.com/subrotoice/test9.git  // Working, Here brunch name main9
git push -u origin main9 // Push to main9, Error: if use master as brunch name
git pull origin master // Change in github, it take effect in local reprository 

#VS Code--- Command dorkar nai, Sob visually kora jai
https://www.youtube.com/watch?v=2oihkInZ880  (Hindi)
1st time step: -----(Local: 1-3, Remote: a-d)--------------
1. Initialize Repository // https://prnt.sc/V7oDXeeOi9CO
2. Commit  // Visually Commit
3. COnfig Git(If ask)

a. Add Remote  // Visually Commit https://prnt.sc/-IWSFNeadc1H
b. Push  // Commit and push option ase vscode
c. Github Auth
d. Push Again (If required)

2nd Time (Old Project):
1. Pule (clone) // https://prnt.sc/K2us0_eYZFuq
2. Commit

a. Push
# https://prnt.sc/5ii9wCPT9Qut // Change in github, it take effect in local reprository

언급URL : https://stackoverflow.com/questions/1443210/updating-a-local-repository-with-changes-from-a-github-repository

반응형