Gars are traditionally considered primitive fish.
We invalidated that earlier when the clade Holostei was dismantled by the LRT and even earlier when the LRT nested the garfish (Lepisosteus, Fig. 3) with sticklebacks and sea horses.
In the large reptile tree (LRT, 1516 taxa, subset Fig. 1) swordfish and gars are sister taxa at the base of the seahorse clade, derived from the barracuda clade. Swordfish and gars seem to differ quite a bit from one another, but currently there are no tested transitional taxa between them.

Figure 1. Subset of the LRT focusing on ray fin fish and showing a hatchling swordfish and an adult gar.

Figure 3. Subset of the LRT focusing on bony ray fin fish and kin. Here Devonian Cheirolepis nests with extant deep sea Malacosteus. More taxa here. The flying fish, Exocoetus, nests with the swordfish, Xiphias, close to Lepisosteus, the gar.
No one has ever put gars and swordfish together before.
Because they really do not look alike overall (Figs. 1, 2). Someday some taxon might come between them, but presently none do.

Figure 2. Extant swordfish (Xiphias) to scale with Eocene swordfish (Blochius). Note the longer, more gracile swordfish ancestor, Blochius.
It might help
if you saw a swordfish (Xiphias) hatchling which has two elongate jaws with teeth (Figs. 3,4), not just a toothless sword and toothless mandible as seen in the adult (Fig. 2).

Figure 3. Adult gar fish (Lepisosteus) compared to look-alike swordfish (Xiphias) hatchling.
The Florida Museum reports,
“Gars are slow growing fishes that are relatively long lived. Newly hatched gars are 8 to 10 mm in length. Hatchlings attach themselves to vertically to submerged objects by an adhesive disc on their snout. Young remain attached by the adhesive disc until the yolk sac is absorbed (about 9 days). After the absorption of the yolk sac the young are able to remain horizontal, take their first aerial breath and begin feeding.”
Xiphias gladius (Linneaus 1758; Gregory and Conrad 1937; up to 4.5m in length) is the extant swordfish, derived from the barracuda, Sphyraena. 1cm long hatchlings more closely resembled little barracudas, then little sailfish before reducing the long dorsal fin. The sword is not used to spear, but to slice and maim smaller fish traveling in schools. The pelvic fins are absent. Larger females produce more eggs, up to 29 million.
Lepidosteus osseus (also Lepisosteus Lacepéde 1803) is the extant longnose gar. Note the jaw joint is in front of the orbit, similar to the stickleback, Gasterosteus. The longest teeth arise from the inside the of jaws, the long vomer. The rostrum is lined by the premaxilla. The maxilla is absent. The traditional jugal is the lacrimal.
First impressions can be misleading.
Score the traits and let the software nest the taxa. If there are no closer sisters, two apparently distinct taxa can nest together.
References
de Lacepéde BG 1803. Histoire naturelle des poissons. Tome Cinquieme. 5(1-21):1-803 + index.
Linnaeus C 1758. Systema naturæ per regna tria naturæ, secundum classes, ordines, genera, species, cum characteribus, differentiis, synonymis, locis. Tomus I. Editio decima, reformata.
https://www.floridamuseum.ufl.edu/discover-fish/species-profiles/lepisosteus-osseus/