Git server Setup and some command instructions

Source: Internet
Author: User

Yum Install Python-setuptools



1, useradd git && echo "123" | passwd--stdin git

2.

Mkdir/home/git/repositories

Chown git:git/home/git/repositories

chmod 755/home/git/repositories


3. Get and install Gitosis

Cd/tmp

git clone https://github.com/res0nat0r/gitosis.git

CD gitosis

Python setup.py Install


4. config gitosis

CP ~/.ssh/id_rsa.pub/tmp

Sudo-h-u git gitosis-init </tmp/id_rsa.pub

sudo chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update


5. Manager gitosis

CD ~

git clone [email protected]:gitosis-admin.git

CD Gitosis-admin


[Email protected] gitosis-admin]# tree

.

├──gitosis.conf

└──keydir

├──[email protected]

└──[email protected]



[email protected] gitosis-admin]# cat gitosis.conf

[Gitosis]


[Group Gitosis-admin]

Members = [email protected]

writable = Gitosis-admin


[Group MAHJONG_RW]

Members = [email protected]

writable = Mahjong


Note: Keydir currently decentralized user public key gitosis.conf file is set group, group members and read and write permissions to the warehouse



git add *

Git commit-am "add mahjong and [email protected] User"

Git push Origin Master




To create a warehouse:

Su-git

CD repositories/

Git init--bare mahjong.git


git clone [email protected]:mahjong.git clone a repository

git push


Git pull


git reset--hard head^ (in Git, with the HEAD of the current version, the previous version is head^, the last version is head^^, of course, 100 versions of the 100 ^ is more easy to count, so write head~100. )


Git checkout--file can discard changes to the workspace, in the command--very important, not--becomes the "switch to another branch" command

Git reset HEAD file can undo the staging area modification (unstage) and re-put it back in the workspace


Git rm is used to delete a file. If a file has been submitted to the repository, then you never have to worry about being deleted by mistake, but be aware that you can only recover files to the latest version (git checkout-file) and you will lose what you modified after the last commit.


git remote add origin [email protected]:p ath/repo_name.git associated with a remote library, associated with using the command Git push-u Origin master to push all the contents of the master branch for the first time. Thereafter, after each local commit, you can use the command GIT push Origin master to push the latest changes whenever necessary.

This article is from the "Attitude decides everything" blog, please make sure to keep this source http://relearn.blog.51cto.com/2605709/1697934

Git server Setup and some command instructions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.