git 中的问题 pull origin <branch name>

problems in git pull origin <branch name>

我想从我的本地系统上传我的 bitbucket 存储库中的所有修改。 将所有代码上传到 bitbucket 存储库的过程

git branch
git branch -a
git checkout <branch_name>
git add .
git commit -m "message"
git push origin <branch_name>
git status

我已经完成了将代码上传到 bitbucket 存储库的上述过程,并且所有修改的文件和代码都已成功上传到特定分支。 但是当从服务器的特定分支获取存储库时,会获取一些文件并丢失一些文件(我使用下面的过程从 bitbucket 存储库中获取代码)

login in my server and go to project folder
git pull origin <branch_name>
then I got the following error => Error in app/controllers/index_controller.rb 
app/models/index.rb
app/views/index.html.erb
db/schema.rb
and so on

然后我按照这些命令

git stash save --keep-index
git stash drop
git reset file_path(app/controllers/index_controller.rb)
git pull origin +branch_name
sudo service apache2 restart

我遵循了上述所有过程,但我从 bitbucket 存储库中获取了一些文件,但丢失了一些文件。 所以请帮助我,我尝试了 6 到 8 次,但我遇到了同样的问题,我错在哪里,错在哪里

取决于您所在的分支。先尝试

git fetch --all

上面将列出所有分支,然后在所需分支上签出,正常从那里拉取。

记住始终确保拉/推是在相同的分支上完成的,即。如果您在本地回购的主分支中,则将其推送到 bitbucket 的主分支中。如果您确定最新代码在 bitbucket 上,您可以尝试 git pull -f origin

(-f 是强制从 bitbucket 获取到本地)