Difference between revisions of "Git/GitLab"

From Ever changing code
< Git
Jump to navigation Jump to search
(Created page with "= Reset a user password = This could be also ''root'' user. <source lang=bash> ubuntu@gitlab:~$ sudo gitlab-rails console ----------------------------------------------------...")
 
Line 21: Line 21:
=> false
=> false
</source>
</source>
= Deployment token =
In course to grant access to a single repository for reading, writting or both we can use feature called ''Deploy Tokens''. Go to <tt>repository > repository settings > Deploy Tokens</tt> to create one.
:[[File:ClipCapIt-191107-092625.PNG]]
Access repository
<source lang=bash>
# Syntax
# git clone http://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git
# Example
git clone https://darkmatter:PLjeFh56F15yJeq8xrZv@gitlab.com/hackerrank1/apache-nginx-ssl.git
Cloning into 'apache-nginx-ssl'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (110/110), done.
...
</source>
;References
*[https://docs.gitlab.com/ee/user/project/deploy_tokens/ Deploy Tokens] Introduced in GitLab 10.7.


= References =
= References =
*[https://gist.github.com/dnozay/188f256839d4739ca3e4 gist]
*[https://gist.github.com/dnozay/188f256839d4739ca3e4 gist]

Revision as of 10:31, 7 November 2019

Reset a user password

This could be also root user.

ubuntu@gitlab:~$  sudo gitlab-rails console
-------------------------------------------------------------------------------------
 GitLab:       11.4.0 (6ebbd70)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.find_by(username: "bob")
                 user = User.find_by(id: 1)    //by id
=> #<User id:5 @bob>
irb(main):002:0> user.password = 'test1234'    //at least 8 characters long
=> "test1"
irb(main):003:0> user.password_confirmation = 'test1234'
=> "test1"
irb(main):007:0> user.unlock_access!
=> true
irb(main):008:0> user.save!
=> false

Deployment token

In course to grant access to a single repository for reading, writting or both we can use feature called Deploy Tokens. Go to repository > repository settings > Deploy Tokens to create one.

ClipCapIt-191107-092625.PNG


Access repository

# Syntax
# git clone http://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git

# Example
git clone https://darkmatter:PLjeFh56F15yJeq8xrZv@gitlab.com/hackerrank1/apache-nginx-ssl.git
Cloning into 'apache-nginx-ssl'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (110/110), done.
...
References

References