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


当前回答

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

其他回答

这个问题非常普遍,我将做一些假设来简化它。我们假设您想要更新您的主分支。

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

git pull origin master

如果你做了更改,并且想避免添加新的合并提交,请使用git pull——rebase。

git pull --rebase origin master

Git pull -rebase即使你没有做任何改变也可以工作,这可能是你最好的选择。

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

git pull origin main

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

完成检查分支的工作流,并从主节点拉出更改

拉所有远程分支

Git拉——全部

现在列出所有分支

Git分支-a

下载分支

Git checkout -b <从>上面的分支列表复制的特征分支名称

显示当前分支。必须在<特征分支>前面显示*

吉特分支

签出从主分支到当前分支的变化

Git拉源主

或将任何其他<feature分支>签入当前分支

Git pull origin <feature-branch>

使用此更新您的本地回购与更新后的远程回购如Gitlab, Github等。

git pull origin master

这应该适用于每个默认回购:

git pull origin master

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

git pull origin my_default_branch_name