First GIT add of old system
I have an old ASP 3.0 system that I want to move into a GIT repo. Currently the most complete version of this system is the production system, so that's what I want to start with.
Should I make a copy of the system and then push the copy to git, then erase the old system and then checkout the new production system from git开发者_StackOverflow中文版? Or is there some other way that I haven't thought of that is better?
Create a Git repository where the production system is (git init .
), add files (git add .
) and commit (git commit -am "Initial commit from live"
) , then git checkout -b live
to call that branch live (and master), add a bare repos as origin (git add remote origin git://server/new_bare_repo.git
) and push there (git push origin master ; git push origin live
).
This would get you a "live" branch which reflects what is currently in production, and a master branch which you use as basis for development.
From then onwards, use the new bare repo for development, on the master branch.
Whenever you want to make something live, make changes (merge, cherry pick, whatever) on the live branch from the master branch or other feature branches, and push the new live branch to the "new bare repo's" live branch. Then go on the Git repo on production and git pull --rebase origin live
, and git push origin live
.
Your bare repo then will always have:
- a "live" branch pointing to whatever is currently deployed
- a "master" branch containing your development
Your production checked out version will always have:
- whatever you wanted to be live
Hope that helps
Should I make a copy of the system and then push the copy to git, then erase the old system and then checkout the new production system from git? Or is there some other way that I haven't thought of that is better?
Yes, that would work. Instead of removing the old directory, I'd suggest renaming it; and after you've checked it out from the GIT repo, do a recursive directory comparison of the new and the old (renamed) directory. If they match (except for the .git
subdirectory, which you can ignore), than you can remove the old (renamed) directory. But for extra safety, wait a couple of weeks with removal -- maybe the file permissions in the new directory aren't right in the new directory, so if you get an error message about that, then you'll have the old directory to look up and copy the permissions from.
精彩评论