Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 686637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:02:41+00:00 2026-05-14T02:02:41+00:00

I’m prettyd comfortable with Git, an I’ve been using it for over a year

  • 0

I’m prettyd comfortable with Git, an I’ve been using it for over a year now. Better yet, I’ve finally convinced a client to switch to it! However, I’m just plain stuck as to how to accomplish what I’m about to describe, or if it’s even possible. Even it it can be done, I wonder if it could be setting us up for a messed-up, unmanageable repository.

I have set up two branches of the code-base. One is “master” and the other is “prod”. The HEAD of prod is always the latest code to deploy to production, and master is the main development branch.

Here’s the problem, though: The client is converting from CVS and most of the developers are still getting used to git. Their CVS workflow involved tagging versions of individual files for production, then updating the servers using the tag. Unfortunately, this has led to sloppy practices like committing unrelated changes together and then tagging the files after-the-fact, and keeping lots of junk files in their main working tree, etc… and the devs want to know how they can do the following:

In their local repos, they hack and commit to their hearts’ delight, then at the end of the day, be able to run a command that takes a list of files whose commits over the day get merged with their local prod – and only those files – even if those commits combine changes to other files.

I know how to split commits with git rebase --interactive, but I have no clue how I would automate splitting commits at all, never mind the way I want to.

I do realize the simplest thing would be to just tell them to switch the their prod branches, checkout the files from their master branches into the working tree then commit to prod. My problem with that is losing the history of their commits over the day.

Has anyone else out there tackled this with a script or something, or do I have to just goad the devs into better behavior – and risk them completely rejecting Git?


Here’s the solution I finally cooked up. It’s a simple shell script that seems to do exactly what I want, even if it’s not the most elegant solution. I’ve only tested a few scenarios, but the file’s change history is preserved and if the commits from the dev branch are later merged in whole git seems to do it cleanly!

#!/bin/sh
set -e
dest_branch=$1
file=$2
current_branch=$(git branch | sed 's/^\* //;/^\s/d')
( 
    set -e 
    git format-patch --stdout --full-index -M -C -B --ignore-if-in-upstream $dest_branch -- $file
    git checkout $dest_branch 
) | git am
git checkout $current_branch
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:02:41+00:00Added an answer on May 14, 2026 at 2:02 am

    Those developers still have a very “file-centric” vision instead of a “repository-centric” approach (based on revision for SVN or commits for Git)!
    They need to read “What are the basic VCS concepts every developer should know?” 😉
    (it is originally about ClearCase but still relevant for CVS users confronted to a DVCS)

    That said, one way to bridge the gap in the particular scenario would be to:

    • at the end of the day of hacking, create a special branch from the current HEAD
    • make a final modification for only the right files (the one for the prod)
      The modification could be for instance some kind of special keyword extension, just for the sake of marking them as “to be merged to prod”.
    • merge that special branch to their local prod: in one commit, only the right files are merged.

    That way, the history for those files is preserved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Remember that binding is only refreshed when a change is… May 16, 2026 at 1:59 pm
  • Editorial Team
    Editorial Team added an answer no it's not necessary that everytime view state of a… May 16, 2026 at 1:59 pm
  • Editorial Team
    Editorial Team added an answer Not necessarily an answer to the question, but a point… May 16, 2026 at 1:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.