在我的master
分支上,我有很多不需要的文件:
good_file1
good_file2
bad_file1
bad_file2
good_file3
在我的temp
分支上,我只提交了好文件:
good_file1
good_fil2
good_file3
我希望拥有master
分支与temp
分支完全相同。
我要做的是:
git checkout master
git reset --hard new15
git push origin master
我得到了
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ''
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
但是现在,当我执行git pull
时,我正在提取bad_files。另外,我不能使用force
,因为分支是受保护的。我该怎么办?
答案 0 :(得分:0)
如果您使用的是github,则应发出请求请求,否则请发送请求:
您想要将分支合并到master。
git checkout master
git pull origin master
git merge temp
git push origin master
签出https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging