[SWIFT] Must-see for beginners! How to manage your Xcode project on Github

Overview

Hello everyone.

Previously, I explained the commands of Github over two articles.

Let's understand github! ① Let's understand github! ②

However, even if you understand the meaning of the command, there is not much information that you can understand the specific flow from creating a new repository on Github to managing it. So, this time, I'll try to manage the Xcode project on Github and use the simple branch and commit functions!

*** * The content I will tell you this time may be easy to do on the X code, but in pursuit of clarity, this time it is an article for those who want to manage anything on GitHub. I will. Please note. *** ***

Before reading this article, I encourage you to take a closer look at Git from the beginning! https://github.com/takanabe/introduction-to-git

environment

・ Xcode --11.3.1

・ Git --2.26.0

· CLI-Terminal

Create an X Code Project!

First, let's create an X Code project! You don't have to do anything special here, so feel free to name and create the file.

*** I created a file called GithubTest! ***

スクリーンショット 2020-11-05 18.27.06.png

Let's initialize the file!

Next, let's open the terminal!

When you open the terminal, you should see something like the following.

Terminal


○○○○○@xxxxxxxxxxMBP ~ %

Type the displayed *** "cd" *** command and drag and drop the created Xcode project to the terminal! !! By the way, *** "cd" *** is an abbreviation for *** change directory ***

Terminal


○○○○○@xxxxxxxxxxMBP ~ % cd /Users/File creator/Desktop/GithubTest 

*** Put the file in the terminal and press enter! !! *** ***

Then the terminal will recognize the file.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest %

Next, let's tell you the information of the person who works and the email address!

Decide your own username and email address

Terminal



git config user.name  Yamada Taro //The name of the person who works
//enter
git config user.email [email protected]  //My email address
//enter

This time, I registered with Taro Yamada

This completes the initial settings.

Create a new repository on Github!

Visit Github! https://github.com/join

If you haven't created a Github account, register. Although it is in English, it is fairly easy to register.

If you can register, you will be confused by the various functions, but one is important. What you do on Github is to create a new repository.

If you have registered, you will find a *** new *** button on the top left of Github. Click on it.

スクリーンショット 2020-11-05 19.14.10.png

Then you will see a screen like the one in the picture below.

スクリーンショット 2020-11-05 19.18.19.png

Let's decide the Repository name! I made it the same as the Xcode file name. Check public, you don't need to check the item of Initialize this repository with.

Then click Create repository!

If you see the screen below, you are successful!

スクリーンショット 2020-11-05 19.21.49.png

Register your X Code project on Github!

At this point, the rest is super easy!

Simply put, just execute the command in the *** ... or create new repository on the command line *** part of the picture below. You can manage your X Code project on GitHub.

Let's type the following commands in order

git init

The git init command is a command to initialize. Think of it as a signal that you're going to type in the git command from now on.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git init

When you execute the command. .. ..

Terminal


Reinitialized existing Git repository in /Users/File creator/Desktop/GithubTest/.git/

If you get a reply like this, the initialization is successful.

git add .

Don't think it's git add README.md next, but type in git add README.md! !!

Even if you type it in, you can proceed, but be careful as it will be confusing! !!

Well, let's get back to the story! *** Let's do git add. ***

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git add . 

*** The git add. *** command is a command to prepare (set) to commit "all the contents of the Github Test file".

Even if you type this command, no message will be returned.

git commit -m ""

Next, we will commit. commit is a command that records repository work. At this stage, I haven't written any code, but you can register even if it is empty, so let's register.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git commit -m "first commit"

"" The contents here can be changed freely. At first, "first commit" is fine.

When you press the enter key, a lot of English comes out, but please be assured that the contents of the X code file are simply read.

Now, let's check if the commit is done properly.

The command to check is git graph

Execute it, and if it looks like the following, the commit is successful.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git graph
* 9e865bb  (HEAD -> main) 2020-11-05 Yamada first commit

git branch -M

This time you don't need to run this command!

This command changes the name of the core branch.

Let's implement it for the time being.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git branch -M master //Rename to master
//I will check
○○○○○@xxxxxxxxxxMBP ~ GithubTest % git branch
* master
○○○○○@xxxxxxxxxxMBP ~ GithubTest % git graph
* 9e865bb  (HEAD -> master) 2020-11-05 Yamada first commit

**** The branch name is master *** This time, there is no problem with main, so let's proceed with main as it is.

git remote add origin 〜###

Use this command to publish your code.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git remote add origin [email protected]:Your account name/GithubTest.git

There is no particular response from the terminal.

git push -u origin###

This command is used to send the contents of the local repository of the current branch to the remote repository. The local repository here is GithubTest, which I have now. And the remote repository is the file required to publish the contents of the local repository GithubTest to Github.

This is a file on the terminal, so it has no reality.

Let's execute the command for the time being

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % git push -u origin main

I think that various commands will come out, but ... If the following response is returned at the end, push is successful.

Terminal


Branch 'main' set up to track remote branch 'main' from 'origin'.

The remote repository that does not have the actual situation mentioned above is the origin main.

Let's check it.

Terminal


○○○○○@xxxxxxxxxxMBP ~ GithubTest % GithubTest % git graph
* 9e865bb  (HEAD -> main, origin/main) 2020-11-05 Yamada first commit
yamazakishunta@yamazakntanoMBP GithubTest % 

origin / main has been added! This is a remote repository. It's a file that doesn't actually exist.

Please note that you must go through a remote repository to upload to Github.

Check it out on Github!

When I update the site on Github. .. ..

スクリーンショット 2020-11-06 0.14.07.png

It's a success displayed like this! !! !! !!

By the way, press the green Add a README. You can create a README. Write a brief description of the app in the README.

When implemented, it looks like this.

スクリーンショット 2020-11-06 0.20.31.png

Did you see this word somewhere? That's right. The git add README.md command. I didn't run the command above as this is added manually.

Continue to Part 2

How was that? It's a lot of work at first, but once you get used to it, it's very simple and you can publish your code.

However, unfortunately, this alone is not enough for application development.

In actual app development, you need to work on or merge branches. In Part 2, I would like to share how to use Github with actual development in mind!

Recommended Posts

Must-see for beginners! How to manage your Xcode project on Github
Must-see for beginners! Specific method to manage X code project on Github ②
[Spring Boot] How to create a project (for beginners)
How to use GitHub for super beginners (team development)
[RSpec on Rails] How to write test code for beginners by beginners
[Tips] How to solve problems with XCode and Swift for beginners
[Eclipse / github] Let's share the project created with eclipse on github For beginners
[Ruby] How to use slice for beginners
[For beginners] How to debug in Eclipse
How to build a Ruby on Rails environment using Docker (for Docker beginners)
[For beginners] How to implement the delete function
[For super beginners] How to use autofocus: true
How to implement login request processing (Rails / for beginners)
[For beginners] How to operate Stream API after Java 8
How to run Java EE Tutial on github on Eclipse
Explanation of Ruby on rails for beginners ④ ~ Naming convention and how to use form_Tag ~
[Must-see for apprentice java engineer] How to use Stream API
[For Ruby beginners] Explain how to freely delete array elements!
For Java beginners: List, Map, Iterator / Array ... How to convert?
[Rails] How to display error messages for comment function (for beginners)
How to deploy on heroku
How to uninstall if you have updated to Java 9 on your Mac
How to make a hinadan for a Spring Boot project using SPRING INITIALIZR
[For beginners] How to get the Ruby delayed railway line name
[Ruby on Rails] How to avoid creating unnecessary routes for devise
How to get JDK 11 on your mac in a comfortable way
How to display characters entered in Spring Boot on a browser and reference links [Introduction to Spring Boot / For beginners]
How to deploy jQuery on Rails
How to push from Tarminal to GitHub
CI for Maven project on AppVeyor
How to deploy Laravel on CentOS 7
How to specify validation for time_field
How to install JMeter for Mac
How to "hollow" View on Android
[Java] How to update Java on Windows
How to install ImageMagick on Windows 10
How to use Ruby on Rails
To beginners launching Docker on AWS
How to deploy Bootstrap on Rails
How to run JavaFX on Docker
How to use Bio-Formats on Ubuntu 20.04
How to install MariaDB 10.4 on CentOS 8
Rails on Tiles (how to write)
To switch JVM for each project
How to install WildFly on Ubuntu 18.04
Addicted to project imports from GitHub
How to make a Maven project
How to build vim on Ubuntu 20.04
[Must-see for beginners] rails_12factor is not required to publish Rails app to Heroku
(For beginners) [Rails] Time saving tech! How to install and use slim
[For Rails beginners] Summary of how to use RSpec (get an overview)
[Java] [For beginners] How to insert elements directly in a 2D array