[SWIFT] Must-see for beginners! Specific method to manage X code project on Github ②

Overview

Hello everyone.

This time, it is a concrete method ② to manage the X code project on Github, so this article is [Must-see for beginners! It is a continuation of the specific method ①] for managing an X-code project on Github.

*** * This time, the content I will tell you can be easily done on the X code or with abbreviated commands, but in pursuit of clarity, this time it is an article for those who want to manage anything on GitHub. We now have. 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

Work on a branch

Let's review the last time a little. You were able to publish the X code file on Github using various commands. スクリーンショット 2020-11-06 0.20.31.png

Is it all right so far?

Let's actually cut the branch and work

Please enter this command

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git checkout -b hotfix main

By executing this command, you can create a hotfix branch that branches off from main.

Let's check!

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git branch
* hotfix
  main

You have a hotfix branch.

Let's work with X-code

Now that we've created a branch, let's actually work with the X-code. You can do whatever you want here. スクリーンショット 2020-11-06 16.57.07.png

By the way, I added a variable to ViewContoroller.

Let's commit!

There was a change in the X Code project, so I will commit. You know the command, right? It's a review of Part 1

First, set the file to commit

Terminal


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

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git commit -m "Add dogs and cats"

In my work, I added dogs and cats, so the commit name is as above. Please give it a name you like.

Terminal


[hotfix 3b0b63c]Add dogs and cats
 1 file changed, 2 insertions(+), 2 deletions(-)

*** If the output looks like this, the commit is successful! *** ***

Let's check.

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git graph
* 3b0b63c  (HEAD -> hotfix) 2020-11-06 Yamada Added dogs and cats
* 9e865bb  (origin/main, main) 2020-11-05 Yamada first commit

it is a good feeling.

Let's reflect it in the remote repository!

Once you've committed, you need to merge. Merge is a command to unify the branches that were branched.

But before that, the hotfix branch hasn't created a remote repository, right?

The remote repository is origin / main. That is, you need an origin / hotfix.

Let's create it!

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git push origin hotfix:hotfix

When I enter this command, a lot of English comes out,

Terminal


* [new branch]      hotfix -> hotfix

If you see something like this, it's OK!

Let's check it.

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git graph
* 3b0b63c  (HEAD -> hotfix, origin/hotfix) 2020-11-06 Yamada Added dogs and cats
* 9e865bb  (origin/main, main) 2020-11-05 Yamada first commit

The origin / hotfix has been created properly.

Let's merge!

Finally, we've reached the point of merging. I'm a little tired. It's a little later. let's do our best.

First, go back to the main branch.

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git checkout main

I will confirm.

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git branch
 hotfix
* main

You can switch firmly.

Let's merge!

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git merge --no-ff hotfix 

The --no-ff command attached to merge is a command to prevent fast-forward.

It's a little confusing, so I'll check it.

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git graph
*   8beb13b  (HEAD -> main) 2020-11-06 Yamada Merge branch 'hotfix' into main
|\  
| * 3b0b63c  (origin/hotfix, hotfix) 2020-11-06 Yamada Added dogs and cats
|/  
* 9e865bb  (origin/main) 2020-11-05 Yamada first commit

If you use the --no-ff command, the marged history will also be split and remain.

However, with a normal marge, I think that the graph will be as shown below without branching. *** ***

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git graph
* 3b0b63c  (main/origin/hotfix, hotfix) 2020-11-06 Yamada Added dogs and cats
| 
|
|
* 9e865bb  (origin/main) 2020-11-05 Yamada first commit

This is fast-forward. It is simpler not to branch, but the disadvantage is that there is no marged history. Which is better depends on company policy and personal preference.

Let's push!

Well, it's finally the end. Let's push! !!

Terminal


○○○○○@xxxxxxxxxxMBP ~ % git push

It's OK if a lot of English comes out.

Let's check it on Github!

スクリーンショット 2020-11-07 1.21.58.png

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

The content of the commit is reflected firmly.

Finally

How was that. This time, I've covered two articles about how to manage your XCode project on Github. Could you publish it on Github? *** Of course, this is not perfect. There are also easier methods and abbreviated commands. *** ***

However, this time the goal is to publish and manage the X Code project on Github. I tried to make it as easy to understand as possible.

We hope that many beginners will enjoy seeing the code on Github through this article.

Well then!

Recommended Posts

Must-see for beginners! Specific method to manage X code project on Github ②
Must-see for beginners! How to manage your Xcode project on Github
[RSpec on Rails] How to write test code for beginners by beginners
[Eclipse / github] Let's share the project created with eclipse on github For beginners
[Must-see for beginners] I changed the display of the posting time to Japanese time [l method]
[Spring Boot] How to create a project (for beginners)
How to use GitHub for super beginners (team development)
[For beginners] Introducing the procedure to Hello, World in C/C ++ language using Visual Studio Code on Ubuntu