bei 发表于 2018-1-10 18:25:57

Gitlab User Guide


[*]Installation
[*]Configuration

[*]Set user name and email
[*]Add SSH keys

[*]Repository

[*]Create New Repository
[*]Clone Existing Repository

[*]Git Operation

[*]Pull
[*]Push
[*]Merge

Installation
  msysGit is a windows version of Git client. Download this installation package and install it: https://github.com/msysgit/msysgit/releases/download/Git-1.9.5-preview20141217/Git-1.9.5-preview20141217.exe
  use default configuration is OK. Just click"Next" button all the way to the end.
Configuration
Set user name and email
  Open Git Bash from desktop (or any folder) by right click:
https://images0.cnblogs.com/blog/218858/201501/061659380784145.jpg
https://images0.cnblogs.com/blog/218858/201501/061659414214057.jpg
  config your user name and email: (They should be the same with your git profile settings)
git config --global user.name "Shishang, Yilin"  
git config
--global user.email "shishangyilin@cienet.com.cn"https://images0.cnblogs.com/blog/218858/201501/061713210159933.jpg

Add SSH keys
  Open Git Gui from start menu:
https://images0.cnblogs.com/blog/218858/201501/061726562653070.jpg
  Click Show SSH Key:
https://images0.cnblogs.com/blog/218858/201501/061726574687369.jpg
  There is no SSH key currently. Click Generate Key:
https://images0.cnblogs.com/blog/218858/201501/061726589218124.jpg
  Git will promt to request you set a passphrase for your SSH key, but it is not necessary. Just click OK to leave it empty:
https://images0.cnblogs.com/blog/218858/201501/061727000153924.jpghttps://images0.cnblogs.com/blog/218858/201501/061727008439037.jpg
  Select the whole SSH key text and click Copy To Clipboard:
https://images0.cnblogs.com/blog/218858/201501/061727019211608.jpg
  Go to Gitlab Profile settings > SSH keys > Add SSH Key:
https://images0.cnblogs.com/blog/218858/201501/061727027506721.jpg
  Paste your key here:
https://images0.cnblogs.com/blog/218858/201501/061727042037477.jpg

  Click the"Title" input box, the>https://images0.cnblogs.com/blog/218858/201501/061727062343592.jpg
  Click Add Key and it is done:
https://images0.cnblogs.com/blog/218858/201501/061727092657831.jpg
  Last Step: Test your SSH link to the git server to verify your key has been added correctly, open Git Bash and input:
ssh git@server_ip_address  Input yes and It's OK When you see Welcome to Gitlab, ...
https://images0.cnblogs.com/blog/218858/201501/061727112656487.jpg

Repository

Create New Repository
To be continued...
Clone Existing Repository
  You can clone the existing project repository to your local machine, so you can work on it.
  First you need to get the source location like below project "first":
https://images0.cnblogs.com/blog/218858/201501/061733341258587.png
  Create a new folder on your computer and open Git Bash:
https://images0.cnblogs.com/blog/218858/201501/061733357815516.jpg
  Clone the source repository:
git clone git@54.65.75.141:shishangyilin/first.githttps://images0.cnblogs.com/blog/218858/201501/061733370315801.jpg
  You can see the downloading information and wait until the clone is done:
https://images0.cnblogs.com/blog/218858/201501/061733382652857.jpg
  After the clone is done, open Git GUI and select Open Existing Repository:
https://images0.cnblogs.com/blog/218858/201501/061733393434427.jpg
  Browse to the repository folder that git clone created (It's in the folder which you created):
https://images0.cnblogs.com/blog/218858/201501/061733407341670.jpg
  Click Open And this is your project workspace, you can commit/checkout/merge changes here:
https://images0.cnblogs.com/blog/218858/201501/061733419375968.jpg

Git Operation

Pull
  Git Pull command is used to update your local repository with the latest version of source repository, it will also merge your local changes with the fetched source repository changes automatically.
  First, create a quick access tool in Git GUI:
https://images0.cnblogs.com/blog/218858/201501/061744316255384.jpg
  The command is git pull:
https://images0.cnblogs.com/blog/218858/201501/061744336254040.jpg
  Then you can simply click the git pull tool to update the repository:
https://images0.cnblogs.com/blog/218858/201501/061744352344983.jpg
  You can see the details like how many changes updated in the message window:
https://images0.cnblogs.com/blog/218858/201501/061744367341725.jpg

Push
  Git Push is used to commit your changes to source repository. Before you start your change, it's better if you pull the changes from source repository first. After you finish your code change, open Git GUI and press F5 to refresh the unstaged changes:
https://images0.cnblogs.com/blog/218858/201501/061744402657878.jpg
  You can see the files list of your change on the left, and click on one file you can see the code diff on the right. Here you can examine your change and when it's ready, select the file you need to commit and click Stage To Commit or press Ctrl + T:
https://images0.cnblogs.com/blog/218858/201501/061744440783246.jpg
  Then the file will be moved from the red zone Unstaged Changes to the green zone Staged Changes (Will Commit). Note: Only the staged changes will be commited. In the Commit Message, input your comments on this commit. You can refer to the issue>#1 (the issue number) and the issue will be connected and closed by the commit. Click Commit when you are done:
https://images0.cnblogs.com/blog/218858/201501/061744466714788.jpg
  After commit, you need to push the changes to the source repository, click Push and confirm it:
https://images0.cnblogs.com/blog/218858/201501/061744495464543.jpg
  You can see the push details if it succeeded:
https://images0.cnblogs.com/blog/218858/201501/061744515151442.jpg
  In the above example, we refered the #1 issue so the issue has been connected to this commit and closed:
https://images0.cnblogs.com/blog/218858/201501/061744546569882.jpg

Merge
  When your change conflicts with the source repository, Git pull or push will fail:
https://images0.cnblogs.com/blog/218858/201501/061750162968785.jpg
  If you failed on pull and your changes has not been commited, commit them:
https://images0.cnblogs.com/blog/218858/201501/061750187657598.jpg
  If you has commited your changes and failed on push, click Remote > Fetch from > origin:
https://images0.cnblogs.com/blog/218858/201501/061750215932368.jpg
  Then click Merge > Local Merge or press Ctrl + M:
https://images0.cnblogs.com/blog/218858/201501/061750236406009.jpg
  Select the branch you want to merge into and click Merge:
https://images0.cnblogs.com/blog/218858/201501/061750257504164.jpg
  If there is no conflicts, the merge will complete automatically.
  Then you can skip the following steps on conflict-resolving, just commit the merge changes and push to source repository according to the instructions after conflict-resolving.
  If there are conflicts, the merge will fail:
https://images0.cnblogs.com/blog/218858/201501/061750275159591.jpg
  In Git GUI you can see the conflict file details. HEAD means your current branch status, origin/master is the source repository branch which you are merging into:
https://images0.cnblogs.com/blog/218858/201501/061750304212104.jpg
  Edit the conflict file, remove the auto-generated notes and merge the changes by editing:
https://images0.cnblogs.com/blog/218858/201501/061750329064146.jpg
  Commit the merge changes:
https://images0.cnblogs.com/blog/218858/201501/061750350315530.jpg
  Push to source repository:
https://images0.cnblogs.com/blog/218858/201501/061750368907227.jpg
  Success!
https://images0.cnblogs.com/blog/218858/201501/061750395314755.jpg
  In the project network view, you can see the merge on two parallel commits:
https://images0.cnblogs.com/blog/218858/201501/061750415936924.jpg
页: [1]
查看完整版本: Gitlab User Guide