git 创建本地存储库_Git –从头开始创建存储库

git 创建本地存储库

git 创建本地存储库

In this chapter we will create users those will be use Git. Create an Git repository and add some code.

在本章中,我们将创建将使用Git的用户。 创建一个Git存储库并添加一些代码。

为Git创建用户 (Create Users for Git)

To use git we need some system users. If we have allready this users we can skip this but if not we will create new users. We will create users for Linux but Windows side is easy to accomplish.

要使用git,我们需要一些系统用户。 如果我们已经准备好该用户,则可以跳过此操作,如果没有,我们将创建新用户。 我们将为Linux创建用户,但Windows方面很容易实现。

First create a group for developers to sum all developers in this group.

首先为开发人员创建一个组,以汇总该组中的所有开发人员。

# groupadd dev

Then create a user by adding to this group named dev

然后通过添加到名为dev的组来创建用户

# useradd -G dev john

Create password for the new user

为新用户创建密码

# passwd john 
Changing password for user john. 
New password:  
BAD PASSWORD: The password is shorter than 8 characters 
Retype new password:  
passwd: all authentication tokens updated successfully.

BAD PASSWORD is for the password length we have used simple password to make things easy but in real systems use strength password.

错误密码是指密码的长度,我们使用简单密码来简化操作,但在实际系统中使用强度密码。

初始化Git仓库 (Initialize Git Repository)

We change our user from root to john.

我们将用户从root更改为john。

# su john

We change our current working directory to the john’s home directory

我们将当前工作目录更改为john的主目录

$ cd

We create a directory for our project named myproject.

我们为我们的项目创建一个名为myproject的目录。

$ mkdir myproject 
$ ls 
myproject

We open myproject directory and check current path.

我们打开myproject目录并检查当前路径。

$ cd myproject 
$ pwd 
/home/john/myproject

End we can create an empty git repository in this directory

结束,我们可以在此目录中创建一个空的git存储库

$ git init 
Initialized empty Git repository in /home/john/myproject/.git/

Repository is the location where directory and related files reside. If we list files in the initialized path we can see that a hidden directory named .git is created. It is the core where magic happens.

存储库是目录和相关文件所在的位置。 如果我们在初始化路径中列出文件,则可以看到已创建名为.git的隐藏目录。 这是魔术发生的核心。

$ ls -la 
total 12 
drwxrwxr-x 3 john john 4096 Oct  7 03:30 . 
drwx------ 5 john john 4096 Oct  7 03:27 .. 
drwxrwxr-x 7 john john 4096 Oct  7 03:30 .git

We have completed the startup of our git repository. Next Chapter we will start working with our project and codes.

我们已经完成了git仓库的启动。 下一章我们将开始处理我们的项目和代码。

LEARN MORE  Git - Branching Operations
了解更多Git-分支运营

删除Git仓库(Deleting Git Repository)

Git repository can be easily deleted without affecting any project file in the current working directory. We know that all git related files reside in the .git hidden folder. So deleting it simple like below will remove git repository.

可以轻松删除Git存储库,而不会影响当前工作目录中的任何项目文件。 我们知道所有与git相关的文件都位于.git隐藏文件夹中。 所以像下面这样简单删除它会删除git仓库。

$ ls -la 
total 16 
drwxrwxr-x 3 john john 4096 Oct  8 03:47 . 
drwx------ 6 john john 4096 Oct  8 03:47 .. 
drwxrwxr-x 8 john john 4096 Oct  8 03:47 .git 
-rw-rw-r-- 1 john john   22 Oct  8 03:47 main.py 
$ rm -Rf .git/

This is same as undo git init command.

这与undo git init命令相同。

翻译自: https://www.poftut.com/git-creating-repository-scratch/

git 创建本地存储库

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值