Discredited by an abysmal showing in nationwide municipal elections earlier this month, the seven-month-old French Cabinet headed by Prime Minister Raymond Barre resigned today.

President Valery Giscard D'Estaing went on television to accept the resignation and tell the nation in a 10-minute address that he had asked Barre to form a new, smaller Cabinet "free" of France's warring political parties.

"You have sent a message to your government," a somber-looking Giscard said in referring to the election results, which gave Socialist and Communist candidates working together control of two-thirds of the city halls in the 221 largest cities. "I got your message."

Despite those results, Giscard said he would not give up his effort to govern from a centrist position of gradual reforms, which have come under attack both from his one-time Gaullist Party allies on the right and from the Socalist-Communist alliance that now appears to be in a strong position to seek to take control of the National Assembly.

He continued to criticize the Gaullists indirectly while appealing to them for support that he admitted is vital to prevent the left from winning the March 1978 legislative elections. Giscard committed the new government to coming up with a program to heal the rift and win the elections but he gave no details.

Gaullist leader Jacques Chirac, who inflicted a humiliating defeat on Giscard's Independent Republican candidates in winning the election for mayor of Paris last week, is to meet Giscard at the Elysee presidential office on Tuesday.

Last August, Chirac's resignation as prime minister triggered the infighting in the centrist and Gaullist coalition that provides Giscard with his majority in the National Assembly.

The president made a passing, relatively favorable mention of Chirac tonight, the first time he has done so since August. But he sharply rejected Chirac's indirect criticism of Giscard's "weakness" and suggested that Gaullist resistance to reform had pushed voters to the left.

He refused to denounce those who voted for the Socialists and Communists, as Chirac has called on him to do. "They are as French as anyone else," the president said. "But they should be aware they are making a dangerous choice."

Barre will name a 5-member Cabinet to carry out Giscard's first priority, "continuing the economic recovery" started by the outgoing government. An economist with strong Gaullist connections but no formal party ties, Barre has won favorable ratings in public-opinion polls.

Informed speculation centered tonight on a sweeping change in the present line-up of Gaullists, Independent Republicans and centerists. Those thought likely to enter the Cabinet include publisher Jean-Jacques Servan-Shriber, former Prime Minister Jacques Chaban-Delmas, and writer -diplomat Alain Peyrefitte.