branch: update the message to refuse touching a branch in-use

The "git branch -f" command can refuse to force-update a branch that
is used by another worktree.  The original rationale for this
behaviour was that updating a branch that is checked out in another
worktree, without making a matching change to the index and the
working tree files in that worktree, will lead to a very confused
user.  "git diff HEAD" will no longer give a useful patch, because
HEAD is a commit unrelated to what the index and the working tree in
the worktree were based on, for example.

These days, the same mechanism also protects branches that are being
rebased or bisected, and the same machanism is expected to be the
right place to add more checks, when we decide to protect branches
undergoing other kinds of operations.  We however forgot to rethink
the messaging, which originally said that we are refusing to touch
the branch because it is "checked out" elsewhere, when d2ba271a
(branch: check for bisects and rebases, 2022-06-14) started to
protect branches that are being rebased or bisected.

The spirit of the check has always been that we do not want to
disrupt the use of the same branch in other worktrees.  Let's reword
the message slightly to say that the branch is "used by" another
worktree, instead of "checked out".

We could teach the branch.c:prepare_checked_out_branches() function
to remember why it decided that a particular branch needs protecting
(i.e. was it because it was checked out?  being bisected?  something
else?) in addition to which worktree the branch was in use, and use
that in the error message to say "you cannot force update this
branch because it is being bisected in the worktree X", etc., but it
is dubious that such extra complexity is worth it.  The message
already tells which directory the worktree in question is, and it
should be just a "chdir" away for the user to find out what state it
is in, if the user felt curious enough.  So let's not go there yet.

Helped-by: Josh Sref <jsoref@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: da5e442f341eed31aa45a152b71c2e3598add47f
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. oss-fuzz/
  15. perl/
  16. po/
  17. refs/
  18. reftable/
  19. sha1dc/
  20. sha256/
  21. t/
  22. templates/
  23. trace2/
  24. xdiff/
  25. .cirrus.yml
  26. .clang-format
  27. .editorconfig
  28. .gitattributes
  29. .gitignore
  30. .gitmodules
  31. .mailmap
  32. .tsan-suppressions
  33. abspath.c
  34. abspath.h
  35. aclocal.m4
  36. add-interactive.c
  37. add-interactive.h
  38. add-patch.c
  39. advice.c
  40. advice.h
  41. alias.c
  42. alias.h
  43. alloc.c
  44. alloc.h
  45. apply.c
  46. apply.h
  47. archive-tar.c
  48. archive-zip.c
  49. archive.c
  50. archive.h
  51. attr.c
  52. attr.h
  53. banned.h
  54. base85.c
  55. base85.h
  56. bisect.c
  57. bisect.h
  58. blame.c
  59. blame.h
  60. blob.c
  61. blob.h
  62. bloom.c
  63. bloom.h
  64. branch.c
  65. branch.h
  66. builtin.h
  67. bulk-checkin.c
  68. bulk-checkin.h
  69. bundle-uri.c
  70. bundle-uri.h
  71. bundle.c
  72. bundle.h
  73. cache-tree.c
  74. cache-tree.h
  75. cbtree.c
  76. cbtree.h
  77. chdir-notify.c
  78. chdir-notify.h
  79. check-builtins.sh
  80. checkout.c
  81. checkout.h
  82. chunk-format.c
  83. chunk-format.h
  84. CODE_OF_CONDUCT.md
  85. color.c
  86. color.h
  87. column.c
  88. column.h
  89. combine-diff.c
  90. command-list.txt
  91. commit-graph.c
  92. commit-graph.h
  93. commit-reach.c
  94. commit-reach.h
  95. commit-slab-decl.h
  96. commit-slab-impl.h
  97. commit-slab.h
  98. commit.c
  99. commit.h
  100. common-main.c
  101. config.c
  102. config.h
  103. config.mak.dev
  104. config.mak.in
  105. config.mak.uname
  106. configure.ac
  107. connect.c
  108. connect.h
  109. connected.c
  110. connected.h
  111. convert.c
  112. convert.h
  113. copy.c
  114. copy.h
  115. COPYING
  116. credential.c
  117. credential.h
  118. csum-file.c
  119. csum-file.h
  120. ctype.c
  121. daemon.c
  122. date.c
  123. date.h
  124. decorate.c
  125. decorate.h
  126. delta-islands.c
  127. delta-islands.h
  128. delta.h
  129. detect-compiler
  130. diagnose.c
  131. diagnose.h
  132. diff-delta.c
  133. diff-lib.c
  134. diff-merges.c
  135. diff-merges.h
  136. diff-no-index.c
  137. diff.c
  138. diff.h
  139. diffcore-break.c
  140. diffcore-delta.c
  141. diffcore-order.c
  142. diffcore-pickaxe.c
  143. diffcore-rename.c
  144. diffcore-rotate.c
  145. diffcore.h
  146. dir-iterator.c
  147. dir-iterator.h
  148. dir.c
  149. dir.h
  150. editor.c
  151. editor.h
  152. entry.c
  153. entry.h
  154. environment.c
  155. environment.h
  156. exec-cmd.c
  157. exec-cmd.h
  158. fetch-negotiator.c
  159. fetch-negotiator.h
  160. fetch-pack.c
  161. fetch-pack.h
  162. fmt-merge-msg.c
  163. fmt-merge-msg.h
  164. fsck.c
  165. fsck.h
  166. fsmonitor--daemon.h
  167. fsmonitor-ipc.c
  168. fsmonitor-ipc.h
  169. fsmonitor-ll.h
  170. fsmonitor-path-utils.h
  171. fsmonitor-settings.c
  172. fsmonitor-settings.h
  173. fsmonitor.c
  174. fsmonitor.h
  175. generate-cmdlist.sh
  176. generate-configlist.sh
  177. generate-hooklist.sh
  178. gettext.c
  179. gettext.h
  180. git-archimport.perl
  181. git-compat-util.h
  182. git-curl-compat.h
  183. git-cvsexportcommit.perl
  184. git-cvsimport.perl
  185. git-cvsserver.perl
  186. git-difftool--helper.sh
  187. git-filter-branch.sh
  188. git-instaweb.sh
  189. git-merge-octopus.sh
  190. git-merge-one-file.sh
  191. git-merge-resolve.sh
  192. git-mergetool--lib.sh
  193. git-mergetool.sh
  194. git-p4.py
  195. git-quiltimport.sh
  196. git-request-pull.sh
  197. git-send-email.perl
  198. git-sh-i18n.sh
  199. git-sh-setup.sh
  200. git-submodule.sh
  201. git-svn.perl
  202. GIT-VERSION-GEN
  203. git-web--browse.sh
  204. git-zlib.c
  205. git-zlib.h
  206. git.c
  207. git.rc
  208. gpg-interface.c
  209. gpg-interface.h
  210. graph.c
  211. graph.h
  212. grep.c
  213. grep.h
  214. hash-ll.h
  215. hash-lookup.c
  216. hash-lookup.h
  217. hash.h
  218. hashmap.c
  219. hashmap.h
  220. help.c
  221. help.h
  222. hex.c
  223. hex.h
  224. hook.c
  225. hook.h
  226. http-backend.c
  227. http-fetch.c
  228. http-push.c
  229. http-walker.c
  230. http.c
  231. http.h
  232. ident.c
  233. ident.h
  234. imap-send.c
  235. INSTALL
  236. iterator.h
  237. json-writer.c
  238. json-writer.h
  239. khash.h
  240. kwset.c
  241. kwset.h
  242. levenshtein.c
  243. levenshtein.h
  244. LGPL-2.1
  245. line-log.c
  246. line-log.h
  247. line-range.c
  248. line-range.h
  249. linear-assignment.c
  250. linear-assignment.h
  251. list-objects-filter-options.c
  252. list-objects-filter-options.h
  253. list-objects-filter.c
  254. list-objects-filter.h
  255. list-objects.c
  256. list-objects.h
  257. list.h
  258. lockfile.c
  259. lockfile.h
  260. log-tree.c
  261. log-tree.h
  262. ls-refs.c
  263. ls-refs.h
  264. mailinfo.c
  265. mailinfo.h
  266. mailmap.c
  267. mailmap.h
  268. Makefile
  269. match-trees.c
  270. match-trees.h
  271. mem-pool.c
  272. mem-pool.h
  273. merge-blobs.c
  274. merge-blobs.h
  275. merge-ll.c
  276. merge-ll.h
  277. merge-ort-wrappers.c
  278. merge-ort-wrappers.h
  279. merge-ort.c
  280. merge-ort.h
  281. merge-recursive.c
  282. merge-recursive.h
  283. merge.c
  284. merge.h
  285. mergesort.h
  286. midx.c
  287. midx.h
  288. name-hash.c
  289. name-hash.h
  290. notes-cache.c
  291. notes-cache.h
  292. notes-merge.c
  293. notes-merge.h
  294. notes-utils.c
  295. notes-utils.h
  296. notes.c
  297. notes.h
  298. object-file.c
  299. object-file.h
  300. object-name.c
  301. object-name.h
  302. object-store-ll.h
  303. object-store.h
  304. object.c
  305. object.h
  306. oid-array.c
  307. oid-array.h
  308. oidmap.c
  309. oidmap.h
  310. oidset.c
  311. oidset.h
  312. oidtree.c
  313. oidtree.h
  314. pack-bitmap-write.c
  315. pack-bitmap.c
  316. pack-bitmap.h
  317. pack-check.c
  318. pack-mtimes.c
  319. pack-mtimes.h
  320. pack-objects.c
  321. pack-objects.h
  322. pack-revindex.c
  323. pack-revindex.h
  324. pack-write.c
  325. pack.h
  326. packfile.c
  327. packfile.h
  328. pager.c
  329. pager.h
  330. parallel-checkout.c
  331. parallel-checkout.h
  332. parse-options-cb.c
  333. parse-options.c
  334. parse-options.h
  335. patch-delta.c
  336. patch-ids.c
  337. patch-ids.h
  338. path.c
  339. path.h
  340. pathspec.c
  341. pathspec.h
  342. pkt-line.c
  343. pkt-line.h
  344. preload-index.c
  345. preload-index.h
  346. pretty.c
  347. pretty.h
  348. prio-queue.c
  349. prio-queue.h
  350. progress.c
  351. progress.h
  352. promisor-remote.c
  353. promisor-remote.h
  354. prompt.c
  355. prompt.h
  356. protocol-caps.c
  357. protocol-caps.h
  358. protocol.c
  359. protocol.h
  360. prune-packed.c
  361. prune-packed.h
  362. quote.c
  363. quote.h
  364. range-diff.c
  365. range-diff.h
  366. reachable.c
  367. reachable.h
  368. read-cache-ll.h
  369. read-cache.c
  370. read-cache.h
  371. README.md
  372. rebase-interactive.c
  373. rebase-interactive.h
  374. rebase.c
  375. rebase.h
  376. ref-filter.c
  377. ref-filter.h
  378. reflog-walk.c
  379. reflog-walk.h
  380. reflog.c
  381. reflog.h
  382. refs.c
  383. refs.h
  384. refspec.c
  385. refspec.h
  386. remote-curl.c
  387. remote.c
  388. remote.h
  389. replace-object.c
  390. replace-object.h
  391. repo-settings.c
  392. repository.c
  393. repository.h
  394. rerere.c
  395. rerere.h
  396. reset.c
  397. reset.h
  398. resolve-undo.c
  399. resolve-undo.h
  400. revision.c
  401. revision.h
  402. run-command.c
  403. run-command.h
  404. scalar.c
  405. SECURITY.md
  406. send-pack.c
  407. send-pack.h
  408. sequencer.c
  409. sequencer.h
  410. serve.c
  411. serve.h
  412. server-info.c
  413. server-info.h
  414. setup.c
  415. setup.h
  416. sh-i18n--envsubst.c
  417. sha1dc_git.c
  418. sha1dc_git.h
  419. shallow.c
  420. shallow.h
  421. shared.mak
  422. shell.c
  423. shortlog.h
  424. sideband.c
  425. sideband.h
  426. sigchain.c
  427. sigchain.h
  428. simple-ipc.h
  429. sparse-index.c
  430. sparse-index.h
  431. split-index.c
  432. split-index.h
  433. stable-qsort.c
  434. statinfo.c
  435. statinfo.h
  436. strbuf.c
  437. strbuf.h
  438. streaming.c
  439. streaming.h
  440. string-list.c
  441. string-list.h
  442. strmap.c
  443. strmap.h
  444. strvec.c
  445. strvec.h
  446. sub-process.c
  447. sub-process.h
  448. submodule-config.c
  449. submodule-config.h
  450. submodule.c
  451. submodule.h
  452. symlinks.c
  453. symlinks.h
  454. tag.c
  455. tag.h
  456. tar.h
  457. tempfile.c
  458. tempfile.h
  459. thread-utils.c
  460. thread-utils.h
  461. tmp-objdir.c
  462. tmp-objdir.h
  463. trace.c
  464. trace.h
  465. trace2.c
  466. trace2.h
  467. trailer.c
  468. trailer.h
  469. transport-helper.c
  470. transport-internal.h
  471. transport.c
  472. transport.h
  473. tree-diff.c
  474. tree-walk.c
  475. tree-walk.h
  476. tree.c
  477. tree.h
  478. unicode-width.h
  479. unimplemented.sh
  480. unix-socket.c
  481. unix-socket.h
  482. unix-stream-server.c
  483. unix-stream-server.h
  484. unpack-trees.c
  485. unpack-trees.h
  486. upload-pack.c
  487. upload-pack.h
  488. url.c
  489. url.h
  490. urlmatch.c
  491. urlmatch.h
  492. usage.c
  493. userdiff.c
  494. userdiff.h
  495. utf8.c
  496. utf8.h
  497. varint.c
  498. varint.h
  499. version.c
  500. version.h
  501. versioncmp.c
  502. versioncmp.h
  503. walker.c
  504. walker.h
  505. wildmatch.c
  506. wildmatch.h
  507. worktree.c
  508. worktree.h
  509. wrap-for-bin.sh
  510. wrapper.c
  511. wrapper.h
  512. write-or-die.c
  513. write-or-die.h
  514. ws.c
  515. ws.h
  516. wt-status.c
  517. wt-status.h
  518. xdiff-interface.c
  519. xdiff-interface.h
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission and Documentation/CodingGuidelines).

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org (not the Git list). The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks