Phương pháp này sẽ chỉ cung cấp cho bạn push thành công, nhưng nó vẫn có thể hữu ích cho bạn:
Khi bạn đẩy đến một chi nhánh ở các vùng xa tương ứng với một trong những chi nhánh từ xa theo dõi của bạn, và đẩy mà thành công, nhánh theo dõi từ xa sẽ được cập nhật. Trong trường hợp mặc định, nơi bạn đã nhân bản từ một kho lưu trữ, điều này có nghĩa là việc đẩy thành công đến master
trong điều khiển từ xa origin
sẽ cập nhật chi nhánh theo dõi từ xa origin/master
. Thay đổi để origin/master
được ghi nhận vào reflog, vì vậy bạn có thể tìm thấy push thành công với:
git reflog show origin/master
Ví dụ, trong một trong các kho của tôi, bạn sẽ thấy:
17f2303 refs/remotes/origin/[email protected]{0}: fetch origin: fast-forward
dd7e0ac refs/remotes/origin/[email protected]{1}: fetch origin: fast-forward
1788ffe refs/remotes/origin/[email protected]{2}: fetch origin: fast-forward
9763bbc refs/remotes/origin/[email protected]{3}: fetch origin: fast-forward
058d0d6 refs/remotes/origin/[email protected]{4}: fetch origin: fast-forward
921f0f1 refs/remotes/origin/[email protected]{5}: fetch origin: fast-forward
8483afd refs/remotes/origin/[email protected]{6}: update by push
18d527f refs/remotes/origin/[email protected]{7}: update by push
1a0fc4a refs/remotes/origin/[email protected]{8}: fetch origin: fast-forward
b19afc6 refs/remotes/origin/[email protected]{9}: fetch origin: fast-forward
9253285 refs/remotes/origin/[email protected]{10}: fetch origin: fast-forward
dfa664f refs/remotes/origin/[email protected]{11}: fetch origin: fast-forward
30ee7c0 refs/remotes/origin/[email protected]{12}: update by push
ad11e76 refs/remotes/origin/[email protected]{13}: fetch origin: fast-forward
c337975 refs/remotes/origin/[email protected]{14}: update by push
1ff03bd refs/remotes/origin/[email protected]{15}: update by push
7fb1c8d refs/remotes/origin/[email protected]{16}: fetch origin: fast-forward
452c8fa refs/remotes/origin/[email protected]{17}: fetch origin: fast-forward
6c79a16 refs/remotes/origin/[email protected]{18}: update by push
11d9c4a refs/remotes/origin/[email protected]{19}: fetch origin: fast-forward
Ví dụ, bạn có thể nói điều này rằng lần đẩy gần đây nhất của tôi được cập nhật origin/master
từ 18d527f
đến 8483afd
.
Nếu bạn cần phải dựa vào điều này, bạn sẽ cần phải dừng việc từ chối hết hạn sau thời gian mặc định (90 ngày IIRC).
Nguồn
2012-01-09 16:00:25
Hoàn hảo! Cảm ơn bạn. FWIW, reflog của tôi là hiển thị các mục từ 9 tháng qua, và tôi đã không làm bất cứ điều gì để ảnh hưởng đến hành vi của nó kể từ lần đầu tiên tôi cài đặt. – Clayton
@Clayton: Điều đó có thể chỉ có nghĩa là bạn chưa kích hoạt 'gc --auto'; nó sẽ hết hạn reflog cũ hơn 90 ngày mặc định. Chỉ cần đặt 'gc.reflogExpire' thành' never' (hoặc cái gì đó lớn hơn) nếu bạn muốn mọi thứ ở lại như vậy. – Cascabel
Đối với người học git: để đặt reflog thành không bao giờ hết hạn đối với tất cả repo cục bộ của bạn, hãy thực hiện: 'git config --global gc.reflogExpire never' tại dòng lệnh. –