Tôi không muốn lấy tất cả các chi nhánh từ nguồn gốc vì có rất nhiều chi nhánh. Tôi chỉ muốn theo dõi một vài (ví dụ: master
) và các chi nhánh của tôi (được tổ chức theo my_name
thư mục con). Tôi có thể làm như sau:Tôi có thể chỉ định trong .git/config để tìm nạp nhiều refspec không?
$ git fetch origin refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch
Tôi muốn chỉ định "tập hợp" các refspec là mặc định là git fetch
. Tôi đã cố gắng
$ git config remote.origin.fetch refs/heads/my_name/*:refs/remotes/origin/my_name/*
$ git config --add remote.origin.fetch refs/heads/master:refs/remotes/origin/master
Nó thất bại:
$ git config remote.origin.fetch
refs/heads/my_name/*:refs/remotes/origin/my_name/*
error: More than one value for the key remote.origin.fetch: refs/heads/master:refs/remotes/origin/master
Tôi cũng thử như sau nhưng nó cũng thất bại:
$ git config remote.origin.fetch 'refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch'
$ git fetch
fatal: Invalid refspec 'refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads/master:refs/remotes/origin/master refs/heads/some_branch:refs/remotes/origin/some_branch'
Lưu ý: Git 1.7.11
Lưu ý: kể từ Git 2.1 (tháng 8 năm 2014), bạn có thể ghi đè truy vấn tìm nạp trên cơ sở mỗi lệnh (nghĩa là chỉ cho một lệnh), với tùy chọn tìm nạp mới '--refmap =': xem [câu trả lời của tôi bên dưới] (http://stackoverflow.com/a/25098004/6309) –
VonC