Reputation: 259
We have this software which lived without version control for a long time, both in the production environment and the development one, with developers patching manually the files at every change (or changing only the production env for hotfixes, sometimes). Like in the jungle. Now, we are putting this under Git version control: I created a repo on the production env with a "master" branch, and pushed it into a new "origin" remote on a dedicated server. Now I'd like to have the dev env as a working copy too, but I'd like to NOT lose the differences with the prod env (something might be useful, who knows?).
I guess a possibility would be: a) moving away all the files b) cloning from origin c) re-moving my files in their original positions
In this case, probably Git would correctly highlight differences between the two codebases. There is a less brutal way to obtain the same result?
Upvotes: 2
Views: 106
Reputation: 2579
You need to decide on a long-term git workflow. A simple one would be to:
You already have production in master, so you can do the following to get dev in "development"
At this point, you will have a master (production) branch and the development branch in the same git repository, both on your working directory, and on the origin server.
You may now do diffs between either branch's commits and see the changes.
You may also maintain each branch separately. Eventually, you can decide to merge commits from development into master as you see fit, or else cherry-pick (hotfix) specific commits on both.
Upvotes: 3
Reputation: 4628
git init
in the soon-to-be working copy to initialize repogit add remote origin ...
to add reference to remote repositorygit fetch origin
to make the remote branches available without modifying you local filesgit checkout -b dev
to create development branchgit add :/ && git commit
to add and commit all local changesNow you have your dev env committed in a branch and you can work with it from here. Push it to make it available on the dedicated server as well.
Upvotes: 1
Reputation: 8345
On your development machine initialize an empty Git repo: git init .
. Add the origin repo: git remote add ...
. Fetch all the changes from the remote origin repo: git fetch origin
. Fetching will only create a remote branch origin/master
, and will not affect local files at all. Diff the local files against the remote branch you just fetched from the origin repo.
Maybe before you fetch you can commit all the local files into a local branch. That would make it more comfortable.
Upvotes: 0