git|git 查看当前git用户_新Git用户使用方法

git 查看当前git用户
This post is a tutorial for new users to set up git and clone and use the first repository. This post introduces how to start using git for new users. This post does not introduce details of how to use git commands. Please refer to the git manual or other tutorials for how to commit, push, etc.
这篇文章是一个教程,供新用户设置git并克隆和使用第一个存储库。 这篇文章介绍了如何开始为新用户使用git。 这篇文章没有介绍如何使用git命令的详细信息。 请参阅git手册或其他教程,了解如何进行提交,推送等。
In this post, we introduce how to set up keys for git, how to configure non-standard SSH port for git, and how to use the first git repository.
在本文中,我们介绍如何为git设置密钥,如何为git配置非标准SSH端口以及如何使用第一个git存储库。
用户的SSH私钥/公钥对 (Users’ SSH private/public key pairs)
Every user of git, administrator or a normal user, need to have a private/public SSH key pairs in ~/.ssh.
每个git用户,管理员或普通用户都需要在?/ .ssh中具有私钥/公钥SSH密钥对。
New users need to generate the key pairs (if they don’t have one) by executing this command:
新用户需要通过执行以下命令来生成密钥对(如果没有密钥对):

$ ssh-keygen -t rsa

After generating the key pairs, the user can give the public key (~/.ssh/id_rsa.pub) to the git server administrator and ask he/she to create a account and repository.
【git|git 查看当前git用户_新Git用户使用方法】生成密钥对后,用户可以将公共密钥(?/ .ssh / id_rsa.pub)提供给git服务器管理员,并要求他/她创建一个帐户和存储库。
After the git server administrator adds the new user by its public key to the git server, the user can starts to use git.
git服务器管理员通过其公共密钥将新用户添加到git服务器之后,该用户即可开始使用git。
非标准SSH端口 (Non-standard SSH port)
This section only for the git servers that use non-stardard SSH port, i.e. other than 22.
本部分仅适用于使用非标准SSH端口(即22以外)的git服务器。
If sshd is listening on non-standard port(s) on the git server, for example 22111, the user should set SSH to use the special port. We use example.org:22111 as the example here.
如果sshd正在git服务器上的非标准端口上侦听,例如22111,则用户应将SSH设置为使用特殊端口。 我们以example.org:22111为例。
Put these two lines in your ~/.ssh/config file:
将这两行放在?/ .ssh / config文件中:
Host example.org Port 22111

If this ~/.ssh/config file doesn’t exist, you should create it first and set it’s mod to 744:
如果此?/ .ssh / config文件不存在,则应首先创建它,并将其mod设置为744:
$ chmod 744 ~/.ssh/config

创建新的存储库 (Create the new repository)
This section only for users to create new repository. If the user is to use an already exist repository, please skip this section. Besides, the steps in this section only need to be done once for one repository.
本部分仅用于用户创建新的存储库。 如果用户要使用已经存在的存储库,请跳过本节。 此外,对于一个存储库,本节中的步骤仅需要执行一次。
We use the example that the administrator create repository repo1 for user1 and give user1 write privilege to this repository. We assume the address for this repository is git@example.org:repo1.git . Now we introduce how does user1 create the new repository repo1.
我们以管理员为用户1创建存储库repo1并为该存储库授予user1写入特权的示例为例。 我们假定此存储库的地址为git@example.org:repo1.git 。 现在,我们介??绍user1如何创建新的存储库repo1
As user1 has the write privilege on the repo1 repository, it can create this repository on it’s local machine first and then push it to the git server. After pushing it to the git server.
由于user1repo1存储库上具有写特权,因此可以先在本地计算机上创建此存储库,然后将其推送到git服务器。 将其推送到git服务器之后。
These operations are done by user1 on its local machine:
这些操作由user1在其本地计算机上完成:
$ mkdir repo1 $ cd repo1 $ git init $ touch README $ git add README $ git commit -a -m 'first commit' $ git remote add origin git@example.org:repo1.git $ git push origin master

If it successes, the new repository is created on the git server.
如果成功,将在git服务器上创建新的存储库。
使用资料库 (Use the repository)
Please note that step 1 only need to be done for the first time. After getting the repository to a local directory on the user’s local machine, the user only need to follow step 2 to step 5.
请注意,只需要第一次执行步骤1。 将存储库获取到用户本地计算机上的本地目录后,用户只需要执行步骤2到步骤5。
1. Clone the repository for the first-time. You only need to do it once for the first time, for the later usage of this repository, you continue use this local directory.
1.第一次克隆存储库。 您只需要第一次执行一次,就可以在以后使用此存储库时继续使用此本地目录。
$ git clone git@example.org:repo1.git

A directory named repo1 will be created in the current directory.
将在当前目录中创建一个名为repo1的目录。
If you want to use the repository directory in the previous section, just add these line to the end of .git/config:
如果要使用上一部分中的存储库目录,只需将这些行添加到.git / config的末尾:
[branch "master"] remote = origin merge = refs/heads/master

2. Pull the updates made before by you or the others. Use “git pull” command in the repository’s directory.
2.拉出您或其他人之前所做的更新。 在存储库目录中使用“ git pull”命令。
$ cd repo1 $ git pull

Then you can work on this updated copy of the repository by editing the files.
然后,您可以通过编辑文件来处理此更新的存储库副本。
If you add a file or directory (for example, add directory a/b and file a/t.txt), you can add it to the repository by:
如果添加文件或目录(例如,添加目录a / b和文件a / t.txt),则可以通过以下方式将其添加到存储库中:
$ git add a/b a/t.txt

3. Commit the changes made by you with a message
3.通过消息确认您所做的更改
$ git commit -a -m 'update the files'

4. Push it to the git server
4.将其推送到git服务器
$ git push

By now, your changes have been pushed to the git server. When the others use “git pull” command, they will get the new version of the source codes that have changed by you.
现在,您的更改已被推送到git服务器。 当其他人使用“ git pull”命令时,他们将获得由您更改的新版本的源代码。
You can use “git log” to see the logs of all the commits of this repository.
您可以使用“ git log”来查看该存储库所有提交的日志。
You may be also interested in more git solutions.
您可能还对更多git解决方案感兴趣。
翻译自: https://www.systutorials.com/howto-for-new-git-user/
git 查看当前git用户

    推荐阅读