learning target:
Version management via Git SSH private key public key or HTTPSLearning 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 repositorystudy-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
This directory is our Unity project
3. Create Unity's Git repository locally
We open SourceTree, create a Git repository
, and select "Yes".
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
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
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
and click Add Remote Repository
Get the SSH connection for the project
Copy and enter, choose Github for hosting type, user name is optional
After clicking to confirm, we have to try to click on the remote end
. 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.
We will first pull it, because we need to Synchronize with the remote side first.
Click refresh and the remote branch will appear.
We will pull the main branch to the local branch master to
temporarily store all
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.
When we submit, we enter Github Found a new Push, the name is master, this is a new branch
We click OK, we will automatically create a new branch master
and we can choose to Merged it to the Main branch
Merged successfully
our current Main main branch This is our current warehouse.
Similarly, we have another Master branch
. 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.
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.
Then we push
. At this time, our newly created local branch already corresponds to the remote branch main
We create a script, as a modification,
click submit and push directly to
succeed! ! !