Xcode 13: Setting up and using Git/GitHub

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey guys this is david here in this tutorial i'm going to be showing you everything you need to know about skits and github inside of xcode [Music] to this i'm going to be demonstrating using a live example so let's go to xcode and create a new project let's call this github demo and we'll just keep the defaults next save to our desktop and make sure source control we have create git repository on my mac selected first thing that i'm going to do is demonstrate how to make a commit so right here we have our project you need to go to the second tab right here which is for repositories go on this down arrow and you can see the main branches since we checked off create git repository in this project we have only one commit here so let's go to content view and change this from hello world to this is a test and we'll also change the spacing here and add some comments xcode realizes that we've made changes and it shows you an m next to all the files have changes so we can go over here and see what changes were made now once we have the changes we'll go up to source control and do commit we can see the changes that we have made and we can add our commit message here change text content so once we're ready to commit this we can press the commit one file button down here and then we go back up to this tab and we can see our commits let's make another commit so you can better understand what's going on let's say we rename contents view to main view so we'll rename this and now this gets changed in main view and the demo app so if i go source control commit we can see all the changes so here we can see contents view got renamed to main view and same thing for the struct and also in this project file this was also renamed we can say rename to main view and then commit so that's how you commit messages in git now let's take a look at branching so right now we have this branch that we're currently on let's branch off by going to new branch from main and we can name this as some feature we're going to work on add second page so right now we're still on main we need to check out to this branch and then we'll go to this just go like this new view second view commit the changes sometimes these check boxes aren't marked so you have to mark these say create second view and now these changes are only on this branch so if we go back to main we're not going to see that commit and if we check out the main we're not going to see that file anymore because that's only on this branch take all the changes we've made on this second branch for the second page and merge it onto main so we'll right click and we'll do merge add second page into main and we'll merge that so now main has this we check out to main and once you finish your features you can delete all the other branches so i'll do delete and now we have this with the new file second view what i've demonstrated was basic get operations on your local machine now we want to push this to a remote repository right here so to do that you have to first go to xcode preferences preferences you want to go to the second tab which says accounts and then you're going to click this plus arrow at the bottom after that you're going to get a prompt to select the type of account you would like to add select github so you'll paste in your github username and account and then you need to create a personal access token inside of github so go to github go down to settings and then go down to developer settings and then personal access tokens from here you need to select generate new token note we can put xcode expiration we can put no expiration and then you want to select repo admin org admin public key and anything else that you need but that should be good for now and then you generate this token you get that token and you paste it in where it says the prompt so you'll paste in your github username and account and then you need to create a personal access token all right now that we have that set up we can go back to our project and push all of this to a remote repository so right click on remotes and do new github remote and we're going to call this github demo promote we're gonna keep it public and you can select which account this is going to be under now we press create and now we go to our github account here we can see the remote repository that was just created inside of xcode so we can click on this and see commit history see all the changes we made we can go back and add a readme so just make a readme file and then anything you do inside of the remote you need to pull into your local repository so to do that you go to source control and you do pull and we get the changes from origin main press pull and we can see we just got create readme branch off so let's make another branch we'll say like change color background we'll go to that branch and then we'll go to main view and add a background color here color dot spread so we changed the background color we made all our changes on this branch that we're currently on the change color branch we're going to commit this change background color to red and we're going to select this drop down here and push it to that branch that we're going to create so we commit and push and now once we go to github we can see that we have recent changes so let's compare and make a pull request we'll say change background color and then create the pull request we can request for reviews we can add comments here anything else that needs to be fixed and the other changes once you're satisfied with this new feature we can merge this back onto the main branch so to do that you press merge pull request confirm and then we can delete this branch now if we go back to here we can see we just merged our first pull request so let's go back into our xcode project go to main and we're going to fetch the changes so we have two things that can be pulled in pull the changes and as you can see from the origin we only have one main branch we don't have this branch anymore so now we can delete this because we safely merged onto the main branch okay that pretty much sums it up for this video we went over how to make commits how to branch off how to add github to your xcode and also how to open a pull request thank you for watching this video be sure to like subscribe and leave any comments i'll be posting more videos in the future thank you for watching and have a nice day
Info
Channel: Software Sage
Views: 35,408
Rating: undefined out of 5
Keywords: xcode13, xcode, git, github, source control, swift, ios programming
Id: RYDCwj37ous
Channel Id: undefined
Length: 9min 22sec (562 seconds)
Published: Tue Oct 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.