使用来自GitHub存储库的更改更新本地存储库

我从GitHub本地检查了一个项目,并且该远程存储库已经对其进行了更改。使用最新更改更新本地副本的正确命令是什么?

1422256 次浏览
git fetch [remotename]

但是,您需要将任何更改合并到本地分支中。如果您所在的分支正在Github上跟踪远程分支,那么

git pull

将首先执行获取,然后在跟踪分支中合并

可能:

上一篇:Git Pull OrieMaster

现在:git拉原点主

这应该适用于每个默认存储库:

git pull origin master

如果您的默认分支不同于master,则需要指定分支名称:

git pull origin my_default_branch_name

对于已经设置好的原始主服务器,您只需使用以下命令-

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

这个问题非常笼统,我将做几个假设来简化它。我们假设您想更新您的master分支。

如果您没有在本地进行任何更改,您可以使用git pull删除任何新提交并将它们添加到您的master

git pull origin master

如果您进行了更改,并且希望避免添加新的合并提交,请使用git pull --rebase

git pull --rebase origin master

即使您没有进行更改,EYZ0也可以工作,这可能是您最好的选择。

要从默认分支拉取,新的存储库应该使用命令:

git pull origin main

Github在2020年将默认分支的命名约定从master更改为main。https://github.com/github/renaming

完成检查分支并从master拉取更改的工作流程

调出所有远程分支

git拉取

现在列出所有分支

git分支-a

下载您的分支

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

显示当前分支。必须在前面显示<feature branch>和*

git分支

从master到当前分支的签出更改

git拉取原始主机

或签出任何其他<feature branch>到当前分支

git拉取原点<feature-branch>

在Git Clone之后,如果想获得远程分支使用

git fetch --all

然后结帐到你想要的分店

git checkout the-branch-you-need

使用它来更新您的本地存储库与远程存储库中更新的存储库,如Gitlab,Github等。

git pull origin master

git pull origin master//更改github,在本地复制生效

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