Unity uses Sourcetree for version management via Git SSH private key public key or HTTPS

learning target:

Version management via Git SSH private key public key or HTTPS

Learning Content:

1.Git configuration and SourceTree installation2.Create a Unity project3.Create a Unity Git repository locally4.Create a Git repository remotely5.Sync the local repository with the remote repository

study-time:

2022.2.12


Learning output:

1.Git configuration and SSH configuration and SourceTree installation

Please see my other article in this column

2. Create a Unity project

We create a Unity project, then copy the project path
insert image description here
insert image description here
This directory is our Unity project

3. Create Unity's Git repository locally

We open SourceTree, create a Git repository
insert image description here
, and select "Yes".
insert image description here
We can see that we have a lot of cached files, which have not been saved
. The most important thing is that the remote end is popular, indicating that our current Git repository is Just a local Git repository
insert image description here
After completing the above operations, the git folder appears under our project folder for version management

4. Create a Git repository on the remote

GitLab official website
GitLab is an open source project for warehouse management system. It uses Git as a code management tool and builds a web service on this basis.

It has similar functionality to Github, with the ability to browse source code, manage bugs and comments. It manages the team's access to the repository, it is very easy to browse committed versions and provides a file history repository. It also provides a code snippet collection function to easily reuse code and find it later when needed.

The main difference with GitHub is: GitHub provides public repositories and private repositories, but if you need to use private repositories, you need to charge. Gitlab allows users to set the permissions of the warehouse for free, so that specified people can see the specified content and ensure the privacy of the warehouse.

We create a blank repository on GitHub for testing
insert image description here
insert image description here
insert image description here
We now have a private repository of our own

5. Synchronize the local warehouse and the remote warehouse

The same is true for HTTPS and SSH, but please note that
if it is the HTTPS method, it will pop up to let us log in to the GitHub account (or your Gitlab account).
If it is the SSH method, you must configure the private key and public key before connecting to the
specific configuration method. Please see Another article in my column,
we click the Settings button
insert image description here
and click Add Remote Repository

insert image description here
Get the SSH connection for the project
insert image description here

Copy and enter, choose Github for hosting type, user name is optional
insert image description here

insert image description here

After clicking to confirm, we have to try to click on the remote end
insert image description here
. Now the remote end is no longer popular, so we click. When we can jump to the page of our project, it means that our configuration is successful.
insert image description here
We will first pull it, because we need to Synchronize with the remote side first.
insert image description here
Click refresh and the remote branch will appear.
We will pull the main branch to the local branch master to
insert image description here
temporarily store all
insert image description here
and then directly check the push changes to it immediately -
because our branch is master at this time, but the remote Git There is only one branch main in the warehouse, so I don’t know where to push to, because the two branches do not know each other
. We only pulled down the main before, we know the main locally
but the remote does not know our master.
insert image description here
When we submit, we enter Github Found a new Push, the name is master, this is a new branch
insert image description here
We click OK, we will automatically create a new branch master
and we can choose to Merged it to the Main branch
insert image description here
Merged successfully
our current Main main branch This is our current warehouse.
Similarly, we have another Master branch
insert image description here
. These two branches are exactly the same. The only difference is that the Main branch is the original remote branch
and the Master is the local branch of Git. We push the branch from the local Master. Go to the Git remote end
and it will automatically create the Master branch at the remote end, so we now have two branches on the remote end.
We can choose to merge Master and Mian
Then choose to create the main branch in SourceTree, and then operate on the Mian branch, so that what we push will only affect the Main branch.
insert image description here
insert image description here
Then we bind the newly created branch to the remote branch.
First, the remote main branch, Pull to our newly created local main branch
and choose to submit the merged changes immediately.
insert image description here
Then we push
insert image description here
. At this time, our newly created local branch already corresponds to the remote branch main

We create a script, as a modification,
insert image description here
click submit and push directly to
insert image description here
succeed! ! !

insert image description here

Guess you like

Origin blog.csdn.net/m0_48781656/article/details/122847300