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
・ Xcode --11.3.1
・ Git --2.26.0
· CLI-Terminal
Let's review the last time a little. You were able to publish the X code file on Github using various commands.
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.
Now that we've created a branch, let's actually work with the X-code. You can do whatever you want here.
By the way, I added a variable to ViewContoroller.
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.
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.
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.
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!
The content of the commit is reflected firmly.
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