git同步远端项目到本地

3,806 阅读1分钟

问题描述:

我用create-react-app在电脑A上初始化了项目(引入了antd并按需引入样式),现在再同步到电脑B上,电脑B用create-react-app创建了基本目录结构

添加远程仓库

git remote add origin 仓库链接

查看添加的远程仓库

git remote -v

获取远端更新

git fetch origin

建立分支追踪

git branch --set-upstream-to=origin/<branch> master

pull分支

git pull
#如果报错:refusing to merge unrelated histories,则用下面的命令
git pull --allow-unrelated-histories

**如果报错:Please commit your changes or stash them before you merge.**这是因为本地代码和远端代码起了冲突,我这里选择让远端覆盖本地,也可以根据需要选择提交

git覆盖本地命令

git reset --hard origin/master