43 lines
724 B
Markdown
43 lines
724 B
Markdown
# Create git server from scratch
|
|
|
|
## Create bare git on server
|
|
1. Install git on server
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install git
|
|
```
|
|
|
|
2. Create directory for git
|
|
```bash
|
|
mkdir <directory_name>
|
|
cd <directory_name>
|
|
```
|
|
|
|
3. Initialize bare repository
|
|
```bash
|
|
git init --bare <project>.git
|
|
```
|
|
|
|
4. Set permission (optional)
|
|
```bash
|
|
chown -R <user>:<group> ~/<directory_name>/<project>.git
|
|
```
|
|
|
|
## Push code from your computer
|
|
1. Go to local repository
|
|
```bash
|
|
cd <repository>
|
|
```
|
|
|
|
2. Add remote repository
|
|
```bash
|
|
git remote add origin <server_credential>:~/<directory_name>/<project>.git
|
|
|
|
# sample
|
|
git remote add origin nik-deb:~/git/automation.git
|
|
```
|
|
|
|
3. Push code as main
|
|
```bash
|
|
git push -u origin main
|
|
``` |