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

  • SEARCH
  • Home
  • 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 3320536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:57:18+00:00 2026-05-17T22:57:18+00:00

I’m trying to refine a personal git workflow to something a little easier to

  • 0

I’m trying to refine a personal git workflow to something a little easier to deal with.

Here’s some background of how I’m using git for purposes of this post:

  • A single developer who is the only one working on the repository.

  • A single copy of the repository that is stored on the local machine.

  • Only two branches “dev” and “master”.

  • All work done on “dev”.

What I’m trying to accomplish is to get to the point where the only commits made to the “master” branch are working production versions based on the confrimed stable “dev” code.

Effectively, what I’m looking to do is:

  1. When everything in “dev” is tested and ready to go, update “master” to be an exact clone of the “dev” branch file tree.

  2. Make minor modifications to “master” to update version numbers, etc…

  3. Commit to the updated “master” branch.

  4. Make a new tag from the “master” branch.

The way that I’m approaching the first step is to checkout the “master” branch and then to run:

'git diff master dev | git apply -'

From what I understand, this effectively blows away anything in “master” and replaces the entire tree with the contents of “dev”. Running “git status” appears to show that this is doing what’s expected based on #1 above.

So, the first question: Is that correct?

After the “master” branch has received these updates, I run my script over to update version numbers in files. Then, I just run a standard “git add .” and “git commit -a” to add all the changes. Finally, I make a new tag and return to the “dev” branch to start coding again.

So, the other question: Is there anything in that process that is going to cause issues?

UPDATE: I should have put this in the first time, but the reason I’m not simply using merge is that changing the version number on master and then trying to merge with changes in dev causes merge conflicts. I know they are irrelevant, but it still stops the process. I’ve used “merge -Xtheirs {branch}” before to deal with it, but I’m not sure about that either.

UPDATE2: Here’s some stuff that I know does not work. I’ve put together a bash script that works on Mac OSX. The first one attempts to use merge:

#!/bin/bash -x

####################
### file: merge1 ###
####################

### clear out the old stuff so you can rerun
rm -rf .git
rm *.txt

### setup the repository
git init

### ignore merge and output files for clarity sake
echo -e "output*\nmerge*" > .gitignore
git add .gitignore

### make the intial commit and move over to dev
git commit -m "Initial commit"
git checkout -b dev

### add stuff to test1.txt in dev
echo -e "FILE1 LINE\nVERSION-XXX\nFILE1 LINE" > test1.txt
echo -e "File2 LINE\nVERSION-XXX\nFILE2 LINE" > test2.txt

### add the files and commit
git add .
git commit -m "Created test1.txt and test2.txt in dev."

### output the state of test1.
cat test1.txt > output-dev-test1-a.txt
cat test2.txt > output-dev-test2-a.txt

### move to master and do a first merge which will work
git checkout master
git merge dev

### Update the version numbers in master and commit it
sed -i "" -e 's/VERSION-XXX/VERSION-1.0/g' test*.txt
git commit -am "Updated version to 1.0 on master"

cat test1.txt > output-master-test1-a.txt
cat test2.txt > output-master-test2-a.txt

### switch back to dev and commit an update to test1.txt
git checkout dev
sed -i "" -e 's/LINE/CHANGED/' test*.txt
git commit -am "Updated content in test*.txt on dev"

### dump test1.txt for reference.
cat test1.txt > output-dev-test1-b.txt
cat test2.txt > output-dev-test2-b.txt

### swtich back to master
git checkout master

######################################################################
### BREAK
######################################################################

### this is where the merge fails because of a conflict
git merge dev

The other way I tried this was with -Xtheirs, which looks like it works at first, but it doesn’t update everything. To see that, remove the last few lines after the BREAK above and replace them with:

### merge with -Xtheirs works here. Proper version "XXX" is showing.
git merge -Xtheirs dev

### but if we update the version number one more time on master
sed -i "" -e 's/VERSION-XXX/VERSION-2.0/g' test*.txt
git commit -am "Updated version to 2.0 on master"

### dump reference file
cat test1.txt > output-master-test1-b.txt
cat test2.txt > output-master-test2-b.txt

### Now, go back to dev and change something in only one of the files
git checkout dev
sed -i "" -e 's/CHANGED/ALTERED/g' test2.txt
git commit -am "Altered only test2.txt on dev."

cat test1.txt > output-dev-test1-c.txt
cat test2.txt > output-dev-test2-c.txt


### are finally return to master and merge again
git checkout master
git merge -Xtheirs dev

### dump reference file
cat test1.txt > output-master-test1-c.txt
cat test2.txt > output-master-test2-c.txt

There are no conflicts, but ‘output-master-test1-c.txt’ shows ‘VERSION-2.0’ instead of ‘VERSION-XXX’ which is desired. This appears to have happened because there were no changes to the file. The ‘output-master-test2-c.txt’ file has the expected ‘VERSION-XXX’ sting. The problem, of course, is that the find and replace that tried to update to version 3.0 would miss in test1-c because it wouldn’t recognize the 2.0 part of the VERSION sting.

  • 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-17T22:57:18+00:00Added an answer on May 17, 2026 at 10:57 pm

    You should use real merges instead of the diff/apply hack. This is as simple as

    [master]$ git merge dev
    

    When you run this on the master branch (shown in prompt) you will merge in all changes from dev. Afterwards you can update the version number, commit and create a tag

    [master]$ git commit -a -m "New version number."
    [master]$ git tag version-1.x
    

    It’s as simple as that.

    In fact you don’t really need a master branch at all, you can create a short lived release branch based on dev, create a tag there and delete the branch afterwards.

    [dev]$ git checkout -b release dev
    [release]$ git commit -a -m "New version number."
    [release]$ git tag version-1.x
    [release]$ git checkout dev
    [dev]$ git branch -d release
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.