Tôi có một kho lưu trữ trên github, nói testrepo. Bây giờ tôi muốn thiết lập một kho lưu trữ cục bộ repo
có một chi nhánh origin-master
nơi tôi muốn có thể chỉnh sửa mọi thứ từ kho lưu trữ.Hiểu git: kết nối chi nhánh với một kho lưu trữ từ xa
repo/origin-master <--------> origin/master
Các nhân bản hoạt động tốt:
mkdir repo && cd repo && git init
# not necessary of course:
echo "master" > master && git add master && git ci -m "master"
git remote add origin [email protected]:<username>/testrepo.git
git fetch origin
git branch --set-upstream origin-master origin/master
git checkout origin-master
# create a new file:
echo "for origin-master" > orig-master && git add orig-master && git ci -m "orig-master"
nhưng
git push origin
To [email protected]:<username>/testrepo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:<username>/testrepo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Làm thế nào tôi có thể nói git rằng nếu tôi muốn đẩy tới nguồn gốc, tôi muốn đẩy chi nhánh địa phương origin-master
để origin/master
?
Hiển thị chuỗi không hoạt động, không phải trình tự hoạt động. – jthill