Để theo dõi my question about unavailable branches after svn to git migration, tôi gặp sự cố khác: Tôi không thể đẩy chi nhánh mới vào kho lưu trữ Git trung tâm của mình.Tại sao tôi gặp sự cố khi đẩy chi nhánh mới vào kho lưu trữ Git của mình?
$ git clone ssh://server/opt/git/our_app.git
$ cd our_app
$ git branch my-test-branch
$ git checkout my-test-branch
$ echo test > test.txt
$ git add test.txt
$ git commit test.txt -m "test commit"
[master ed81ec0] test commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
$ git push
Everything up-to-date
Vì vậy, điều này không đẩy chi nhánh của tôi đến máy chủ. Một đồng nghiệp khuyên tôi nên nhìn vào .git tôi/config, trông như thế này:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://server/opt/git/our_app.git
[branch "master"]
remote = origin
merge = refs/heads/master
Tôi đã adviced để tự thêm một mục push:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://server/opt/git/our_app.git
push = refs/heads/*:refs/heads/*
Bây giờ mọi thứ có vẻ tốt hơn:
$ git push
Password:
Counting objects: 1, done.
Delta compression using up to 1 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (1/1), 5 bytes, done.
Total 1 (delta 1), reused 0 (delta 0)
To ssh://server/opt/git/our_app.git
* [new branch] my-test-branch -> my-test-branch
Trong khi làm việc này, nó vẫn cảm thấy như một hack. Cách thích hợp để làm điều này là gì?
Hành vi mặc định cho 'git push' là đẩy các nhánh có đích đến tương ứng tồn tại trên đầu cuối từ xa. Các chi nhánh mới không có điểm đến phù hợp như vậy. Bạn có thể thay đổi hành vi mặc định bằng biến cấu hình 'push.default'. – Amber