Complete Godot version control workflow with Git

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone an often overlooked aspect when making video games is communication collaboration and version tracking this video I'm going to show you the process I'm taking in order to work together with someone and also to be more organized with my own project now let's assume that I'm working on a video game together with a friend and I start some 2D scene and here I create let's say a Sprite Tod and add an icon to it and everything is nice and I want to share this with my friend so that he can work on uh from this point on the project further how would I do that well a straightforward way you would think of would to Simply go into this directory and copy everything and send it to your friend and afterwards he can work and then he can send it back and so on while this is nice your project could get really complicated maybe your friend wants to work at the same time as you on the project and uh it would be really hard to manage that way now this is where git comes in it basically lets you take snapshots of your project and you can have those snapshots and share them with your friend or you can uh even return to a snapshot if you're not happy with the changes you have already done and get back to a state in which you are happy with your project let's see how we use it now before moving on make sure that you have git installed vs code and that you have GitHub account in the description I have attached links on how to get each of those well first of all I am going to Simply initialize a git repository here and I'm simply going to right click and click on git bash here and here I'm going to Simply write git init now that I have written git init you will see here a dogit fer and if you do not have it here make sure to go to view here and have these hidden items selected and we are basically in a local repository now if I wanted to push these changes so that my friend could use them later I would have to use GitHub GitHub is a place in which I can create multiple repositories which are basically just some small projects on which I'm working and you can share these repositories with your friends you can share them with anyone around the world okay so let's just create a new repository public repository I'm going to click on new here and let's call it uh yeah some repo doesn't really matter too much I'm going to have it set to public and I'm going to not change anything here because we already have some stuff locally I click on create repository now that our repository has been created what we have to do is to Simply connect it with our local repository so how do we do that well we go locally into our directory right click and this time we are going to click open with code why do we open it with code because we are going to do some other interesting things from here now we need to open a bash terminal so I'm going to click on Terminal and new terminal and here you can simply go on git bash this is basically the same as opening the git Bash from here so no big changes until now and now we can actually manage our project how are we going to do this well first of all we need to add a remote to it we are basically telling that this local project has to communicate with something that is remotely somewhere in order to do that we are simply going to come here and it's giving us the command get remote add something copying it and I added the remote okay this is great now the next step would be to set our files to the GitHub repository now how would we do that well we can do it in a few ways and I'm going to show you both ways at the same time because you might like one way or another way and either way is really fine so first thing we can do is to say here a nice command which is K status now this is telling us that we have some untracked files what does that mean well files that are not tracked are basically files that are not going to be included in the snapshot that we will take so if we want to include all these files we can add them separately or we can add them all at once and I'm going to show you both ways so let's say that we want to add icon.svg we would simply write git add and you see here that we have some information file so icon. SVG if I write G status right now we can see that we have a file that is ract so it is with green and the other ones are with red now there is another way if you do not wish to use the console we can go here to Source control and you see that already something is uh interesting here we have four changes but we can see that icon. SVG is under staged changes now why is that well because second ago we simply added this icon. SVG to be tracked if I'm doing this again let's say for project. GTO I'm going to write git add project. this is going to be added to Stage changes as well well instead of writing all these we can simply go here and click on plus and click on plus again and again and we can click on minus if we want and again we can track and untrack files as we please now if we wanted to not click on each separate file every time we could simply say G add Dot and this would basically put everything under stage changes or we could come here and add changes click on the plus here and add everything again at stage changes now this is nice but we are not there yet we need to create a snapshot of these changes so again we can do this in two ways through the console or through the source control window and let's first do it through the console so now that I have added let's say uh let's not add everything I added these three files I can simply write git commit and we might need a message for this so I'm going to Simply write DM this comes from message and here let's say uh some Commit This Could Be basically anything now the commit might ask us to tell them who we are and uh we need to tell them our email and our name I already have uh configuration for that I'm going to add it for me but you can simply run these commands with your email and your name and now that we added the configuration I can again write git commit DMM commit and we see that these things have been committed what does that mean again it means that we have taken a snapshot and to better visualize that snapshot we can go to extensions and look for git graph and here on git graph we could say here install to install this extension I already have it installed and again while clicking on Source control we can go here to this little icon and see that we have some commit here now if we wanted to create another commit let's say that we wanted to also add these files we could do it this time from the interface click here and write here a message let's say another commit and click commit here and you see see now in the git graph that we have some commit and then we have another commit okay now the last thing we have to do is to actually push this changes now in order to push these changes to this external repository we have a command which is get push and this will basically take everything that is committed and push it to a branch on our main repository again this can be done in another way through the source control if we simply say publish Branch let's try to do it from uh the console because this should be pretty straightforward so I'm going to write get push and you see that we don't not have an upstream Branch what does that mean it means that on our remote repository there is no Branch named uh Master on which we could push so let's simply say get push set Upstream Regin Master we see that the push has been successful and now if we go back to our repository maybe we refresh it you see that the changes are already here now this is fantastic because now if we share this repository with someone they can simply come here and let's say copy this URL to the clipboard and go for example to another folder and open git bash simply say git clone and paste this now when you're pasting git bash you have to make sure that uh contrl V does not work you have to uh you have to press insert or shift insert or you can simply right click and paste here so be careful about that but yeah other than that if we now close our bash we see that we have some repo and it basically has everything that we already had now while communicating with others is useful itself we still need to know why this is good for us as a solo developer so why could this be good well git offers another feature which is called branches for example let's say that we have here a working version of our project basically we want to add some changes but we are afraid to do those changes because we might break it and then we would have to spend a lot of time to fix it and yeah that would be pretty hard how could we manage that with kid well we could simply create let's say another Branch kid branches are basically if you want to be fancy about it like different timelines through which your project can go so let's see it in practice first of all let's save our current scene CU I remember we did not save it now we have a note to the tscn let's add those changes so scene commit now since we have a snapshot of our master and our scene we know that we can always get back to this point so we can start experimenting let's say we wanted to add some cool new feature we wanted to duplicate this Pride for four times and I don't know spread it around or something doesn't matter too much but we have now a new version of our scene now this version and maybe some other changes that we would like to do could be sent to a different branch where we experiment things so we can simply write G checkout DB and the name of the branch so let's say new cool feature okay we checked out to that branch and now now if we do the same process as we did before we are going to push our changes to that Branch currently you see that our new cool feature branch is at the same level as the master Branch because we have no changes on it but now if I'm going to add my node to thec let's say new feature commit we see that the new feature is currently up here on the new cool feature branch and the master scene is behind our Branch okay if we save this uh now we basically have our feature now if we don't like it let's say we experimented and nothing worked we can simply go back to whatever we had before on master so let's say just right click on Master here and check out Branch we checked out the branch and we click reload here and we see that our scene loaded back to the initial state that it had before we didn't have to go through each Sprite to delete it and you can imagine how you could have worked on something much more complex and you wouldn't have had to go back and delete everything for that project okay but one other thing to do would be the other way around to like what we have done to like the feature that we completed and to want to add it to our main timeline and how would we do that well let's go back to our current branch and now that we are on this Branch we can merge it back into Master now how do we merge well well we could simply say get checkout master and get merge new cool feature oh sorry get merge and basically what we did was to take everything that's on new cool feature and add it here to master and now we are on master and if we reload we see that we have our feature our changes already here okay so this might have been quite a lot but it's the basic of what you should understand when working with Git there are obviously plugins that you could work with with gdo I Tred those plugins but they didn't seem to work as flawlessly and as easily as it bash and as uh this Source control window from vs code and additionally this is a really common practice in programming in general so having this information would help you if you would like to get a job for something different not necessarily video game programming okay but this is basically it if you have any problems you can leave a comment and I'll try my best to help you if you like this and if you want a more in-depth guide regarding it then you can also leave a comment about that and I will make a new video on G because GD is pretty big and a lot of features can be discussed there hey thanks for watching and see you in the next one
Info
Channel: Cashew OldDew
Views: 549
Rating: undefined out of 5
Keywords: godot, git, vscode, version control, godot collaboration, collaboration, tutorial, video games, game development, development, godot engine, godot 4, Learning Godot, Game Design, Programming, Coding, Indie
Id: t2fAD5wPXEk
Channel Id: undefined
Length: 14min 24sec (864 seconds)
Published: Sun Feb 11 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.