Создать голый репозиторий GIT
Небольшой разбор: git не может самостоятельно создать обычный голый репозиторий. Глупый git действительно.
Чтобы быть точным, невозможно клонировать пустые репозитории. Таким образом, пустой репозиторий - бесполезный репозиторий. Действительно, вы обычно создаете пустой репозиторий и сразу же заполняете его:
git init
git add .
Однако git add невозможно при создании открытого репозитория:
git --bare init
git add .
дает ошибку «fatal: эта операция должна выполняться в дереве работ».
Вы также не можете проверить это:
Initialized empty Git repository in /home/user/myrepos/.git/
fatal: http://repository.example.org/projects/myrepos.git/info/refs not found: did you run git update-server-info on the server?
git --bare init
git update-server-info # this creates the info/refs file
chown -R <user>:<group> . # make sure others can update the repository
Решение состоит в том, чтобы создать другой репозиторий в другом месте, добавить файл в этом репозитории и вставьте его в открытый репозиторий.
mkdir temp; cd temp
git init
touch .gitignore
git add .gitignore
git commit -m "Initial commit"
git push (url or path of bare repository) master
cd ..; rm -rf temp
надеюсь, что это поможет u
Этот код работает для вышеупомянутого случая
class UserManager(BaseUserManager):
def create_user(self, mobile_no, role, password=None):
"""
Creates and saves a User with the given email and password.
"""
if not mobile_no:
raise ValueError('Users must have an Mobile No')
user = self.model(
mobile_no=mobile_no,
)
user.set_password(password)
user.activated=True
user.save(using=self._db)
return user
def create_superuser(self, mobile_no, role, password):
"""
Creates and saves a superuser with the given email and password.
"""
user = self.create_user(mobile_no, role=role,
password=password
)
user.is_admin = True
user.activated=True
user.save(using=self._db)
return user
def create_staffuser(self, mobile_no, role, password):
"""
Creates and saves a staffuser with the given email and password.
"""
user = self.create_user(mobile_no, role=role,
password=password
)
user.is_staff = True
user.activated=True
user.save(using=self._db)
return user
class Users(AbstractBaseUser, PermissionsMixin):
object = UserManager()
mobile_no = models.IntegerField(_('MobNumber'), null=True, blank=True,unique=True)
email = models.EmailField(_('Email'), max_length=75, null=False, blank=False)
first_name = models.CharField(_('FirstName'), max_length=50, null=True, blank=True)
last_name = models.CharField(_('LastName'), max_length=70, null=True, blank=True)
role = models.CharField(_('Role'), max_length=70, null=True, blank=True)
location = models.CharField(_('Location'), max_length=70, null=True, blank=True)
date_time = models.DateTimeField(_('DateTime'), auto_now=True, null=True, blank=True)
activated = models.BooleanField(_('Activated'), default=False)
is_admin = models.BooleanField(_('is_admin'), default=False)
is_staff = models.BooleanField(_('is_staff'), default=False)
def __unicode__(self):
return str(self.mobile_no)
def __str__(self):
return str(self.mobile_no)
def get_full_name(self):
return self.first_name + " " + self.last_name
class Meta:
ordering = ['-id']
@property
def is_staff(self):
return self.is_admin
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return self.is_admin
USERNAME_FIELD = 'mobile_no'
REQUIRED_FIELDS = ['role']