- Required Tools
- Installation
- Configuration
3-1. git config
3-2. ssh key
3-3. Gitlab Account - Repository
5-1. Repository Creation
5-2. Update Remote
5-3. Update Local
5-4. Other Operations - References
Check if the required packages are existing:
- Git:
$ git --version
- OpenSSH:
$ ssh -V
- Git for Windows
- TortoiseGit
Note that TortoiseGit is different from TortoiseSVN.
Developers who previously install TortoiseSVN should install TortoiseGit separately.
- Git:
$ sudo apt-get update
$ sudo apt-get install git
- OpenSSH client:
$ sudo apt install openssh-client
-
Git:
-
TortoiseGit:
For Linux, use those commands on terminal;
For Windows, those can be applied on Git Bash:
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
The config info is stored in $HOME/.gitconfig:
[user]
email = [email protected]
name = username
The location of $HOME/.gitconfig:
- For Linux:
~/.giconfig
or/home/your-username/.gitconfig
- For Windows:
C:/Users/Your-Username/.gitconfig
For Linux and Git Bash on Windows:
$ ssh-keygen -t rsa -C "a-title-your-can-remember"
The default location to save the ssh key: $HOME/.ssh/id_rsa
$ cat ~/.ssh/id_rsa.pub
$ ssh-add ~/.ssh/id_rsa
For Windows user, since TortoiseGit is being used, there is a different way to add ssh key:
-
From [start] menu, run [PuTTYgen]:
-
If you have not generated a key using Git Bash, you can [generate] it now:
-
If you already have a key, you can now [load] the key (default path:
$HOME/.ssh/id_rsa
) -
Click [Save private key], save it as .ppk file:
-
In your project repository, right click and navigate to [TortoiseGit] => [Settings]
-
Navigate to [Git] => [Remote], choose a name from [Remote]. for the field Putty Key, browse the folder of your ssh keys, and open the .ppk file your want:
-
Catch the ssh key on terminal or Git Bash and copy, or copy it from PuTTYgen:
$ cat ~/.ssh/id_rsa.pub
-
Login to your GitLab account, navigate to [Profile Settings], go to [SSH Keys] tab, past to [key] area; if the format is correct, the [Title] should be automatically generated:
branch: master
Clone: $ git clone [url] (directory)
Init:
$ git init
$ git remote add origin [url]
$ git status # check changes
$ git add [file(s) separated by whitespace] # add file to commit
$ git commit -m "message" # save the changes locally
$ git pull (origin) (master) # update from remote
$ git checkout -b [branch-name] # for developers and lower
$ git push (origin) (master) # update from local
Resolve conflicts: manually
$ git diff # find the conflicts
Remote modification:
$ git remote rename [old-remote] [new-remote] # renaming
$ git remote remove [remote-name] #remove
Protected branch:
Push directly: Master and higher
Push to a new branch and send merge request: Developer and lower