Git related Questions

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Git related Questions

Post by randi »

I found this guide with pictures very helpful for understanding Git. You might want to read through it.

Assuming you have checked out a copy of the subversion repository with your own local changes, probably the most straight-forward way to transition to git is to setup your own branch. (I'm going to use the command-line here, since the specifics can vary by GUI, but they all use the command-line tools underneath.)
  1. Make a local copy of the repository, either the main one or a fork. A fork is useful if you want to keep your changes on a remote server, but it's not required. For the official repository:

    Code: Select all

    git clone https://github.com/rheit/zdoom.git
    cd zdoom
  2. There have been changes made to the Git repository that aren't in SVN. We will create a new branch starting at the point where the SVN left off:

    Code: Select all

    git checkout -b mybranch 2.7.0
    This creates a new branch called "mybranch" that is currently just a copy of the repository as it was at the last commit to SVN. It also makes it the most currently "checked out" branch. (Note that Git checkout is not the same as SVN checkout! Git checkout is equivalent to both svn update and svn switch.)
  3. Now copy your files from your copy of the SVN repository to the Git directory. I believe the following will work with local changes:

    Code: Select all

    svn export --force <path-to-svn-directory> <path-to-git-directory>
    Otherwise, just copy the files by hand, being sure not to copy any .svn directories.
  4. If you added any files to your repository that weren't in the SVN, be sure and add them to the git repository as well:

    Code: Select all

    git add somenewfile1.cpp
    git add somenewfile2.cpp
  5. Now commit your changes so that they won't be lost when you switch to a different branch:

    Code: Select all

    git commit -a -m "Initial import of my SVN changes"
    The "mybranch" branch should now be an exact copy of what you had in your SVN directory.
  6. Since your personal branch doesn't have any of the changes that occurred since the switch to Git, merge them from master into your branch:

    Code: Select all

    git merge master
  7. Commit this merge, too:

    Code: Select all

    git commit -a -m "Update to current master"
Repeat steps 6 and 7 every time you pull new changes from the remote repository to apply the changes to your personal branch:

Code: Select all

git checkout mybranch    (if it's not checked out already)
git merge master
git commit -a -m "Sync with master"
To get a pristine version of the code from the remote repository without any of your changes:

Code: Select all

git checkout master
To get your changes back:

Code: Select all

git checkout mybranch
Just make sure you commit every change you make to mybranch.
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Git related Questions

Post by Enjay »

Very helpful, thank you. I've read your post through and I think I get it. It's getting a little late here so I'll have to leave trying it until tomorrow but I think that I should be able to work my way through those instructions. I'll also read through the guide tomorrow too. Thanks again.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Git related Questions

Post by Graf Zahl »

For GZDoom I used the brute force way:

I just forked ZDoom, cloned it locally, then copied all GZDoom specific files into it, committed and pushed it to my remote. That way I got everything in, including the git related changes to ZDoom.

The only thing that got lost in the transition was the ZDoom revision number combined with GZDoom's - but with git's handling of the project it wouldn't work anyway.
User avatar
NeuralStunner
 
 
Posts: 12326
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Git related Questions

Post by NeuralStunner »

How is save versioning going to work from here on? Will you still maintain an internal save version?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Git related Questions

Post by Graf Zahl »

Of course, but the number has to be set manually and will only be incremented when something changes.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Git related Questions

Post by Blue Shadow »

Sorry for the off-topicness, but I'm wondering, can you have private repositories on Git, or do they have to be public?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Git related Questions

Post by Graf Zahl »

On Github you have to pay for a private repository - but on Bitbucket you can have them for free.
User avatar
printz
Posts: 2648
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Git related Questions

Post by printz »

Wait, did ZDoom and GZDoom just move to Git? Congratulations!
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Git related Questions

Post by randi »

Yes.

And to answer the previous question, Git also has a built-in option for maximum privacy: Keep the repository on your local machine and never push it anywhere. If you want. That does sort of defeat half the reason for using it in the first place, but it is an option.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Git related Questions

Post by Graf Zahl »

randi wrote:That does sort of defeat half the reason for using it in the first place, but it is an option.
Actually, I do that a lot with private stuff nobody is supposed to see. I think it's one of the most useful features of DVCS's to allow easy versioning of stuff that's never supposed to go public ever.
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Git related Questions

Post by Enjay »

OK, well, I *think* I have now managed to get things doing what I want.

To start with, I followed Randi's instructions and did things via the command line. I didn't auto transfer the stuff from my edited version using SVN because I wasn't doing it for ZDoom and I couldn't find which revision to enter on the command line for GZDoom (everything I tried gave errors). However, as I mentioned, my changes are minimal so I just entered them manually. This meant that I could just download a copy of the repository and edit the files directly without worrying about different versions.

Going through the remaining commands allowed me to get a better idea of how things were working and resolved a couple of misunderstandings on my part (eg I was expecting that creating my own branch would set up a new directory with a copy of the code in it - which doesn't seem to be the case).

Once I had done things using the command line, starting from scratch again, I tried to replicate as much as possible using the shell integration of Git/TortoiseGit. I branched the source, found the menu option that allows me to switch between branches, copied my edits across to my branch and committed them. Fortunately, GZDoom then updated centrally and one of the files that I had edited were part of the update so I grabbed the latest update, pulling it into the master copy on my HD and then I switched to my branch and updated it from my copy of the master. I can only assume that I did things correctly because all my changes are still present, even in the file that was updated, and the updates to the master are also present in my branch (again, including in the file that I have modified).

So, fingers crossed, I think I know how to keep updating my branch with the changes made in the master code.


Now for a final question:
It would make life easy for me if I could check to see if the online main code has changed using a batch file so that I don't have to find the folder and right-click it every time. This is not for my own modified branch but, rather, the copies of ZDoom and GZDoom that I am maintaining for making the DRD builds.

I intend to use the batch file to change to the appropriate directory and then use a Git command to check for updates. So, once my batch file has navigated to the folder where I am keeping the ZDoom Git source code, what is the syntax that I should use in the batch file to have the command line version of Git interrogate the online copy and download and apply any changes that might be present? Is it just "git pull" (which seems to work)?
User avatar
jpalomo
Posts: 771
Joined: Mon May 17, 2010 9:45 am

Re: Git related Questions

Post by jpalomo »

Whenever I compile ZDoom, the version number always reads <unknown version>. Do I need to do anything extra now that ZDoom switched to Git? I've already installed TortoiseGit and added the directory to VC++ Directories. There are no compiling errors showing up.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Git related Questions

Post by Graf Zahl »

Git doesn't seem to set the path environment variable itself automatically. They seem to be focussed on running their tools from the bash shell primarily. Which of course is useless if git needs to be called from external programs. Didn't the git installer give you an option to set it? I only installed git via TortoiseGit but I got a requester where I could choose what configuration I wanted.
User avatar
Enjay
 
 
Posts: 26535
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Git related Questions

Post by Enjay »

And if you have already installed everything and you need to add it to the path manually, this may help.
User avatar
jpalomo
Posts: 771
Joined: Mon May 17, 2010 9:45 am

Re: Git related Questions

Post by jpalomo »

It seems the environment variable was the issue. I added it manually. Compiled exe is now showing version as ZDoom 2.8pre-33-gfb965c5.Thanks for the help.
Post Reply

Return to “General”