GitLab Use Summary

  And to use Git as a summary of GitLab

GitLab based Git, you can use the project as a team to develop, so there is usually a main branch and other branches master, so project members in any one of them not at liberty to push into the main branch can be confusing;

But if the project temporarily only own one, you can operate the master branch.

  1. First, they put forward a public key server or in a local project in
keygen -t rsa -C-SSH " [email protected] " #Gitlab mail account

If on the server, in your home directory, there will be .ssh file, which should generate a id_ras and id_rsa.pub two documents, such as the path of my server is hyq / .ssh, you can view all the command ls -a hidden files

   2. cat id_rsa.pub open the file, then copy all the contents to the SSH Keys under the Profile Settings GitLab, so that you can build server and Gitlab without a password to connect (the default on new projects already in the Gitlab)

   3. Go to the project directory

Git init # initialize 

git the Add - A # workspace file into the staging area, it serves as a cache 

git the commit 'description' # submit -m file to the staging area branch 

git remote add origin ssh: // git @ xx. xx.xx.xx: port number associated warehouse /username/project.git #

Here are a few places to note,

  • One is GitLab upload something to a text file based, including py, txt, log, org, csv etc., other large data files or directory model and cache files, etc., do not upload,

Therefore .gitignore can write a file, which you want to ignore the write up documents, such as my .gitignore file:

train, test, validation is a directory, which stood data, so the suffix is ​​\, best.mdl, nohup.out and __pycache__ file directly write up carried out.

  • There is a Man accidentally already add up all the files, then the next time you create a new .gitignore was too late, we must use the following command
git rf --cache -A # to delete cache files, the file does not delete the workspace

or

git rf --cache 'directory name'

For a file, it is

git rm --cached 'filename'

Be sure to bring --cached, otherwise just git rm or git rf words, not only delete the files in the temporary area, but also the workspace file is deleted

  • Third, if a connection is to start building the http, want to become ssh, it must first delete the associated
git remote rm origin

Then, create a new association

   4. Upload the project

git push -u origin master

Here are a few places to note

  • If you have made changes in the GitLab, such as built README.md file, you must first pull down, and then push
    git pull origin master

 

Guess you like

Origin www.cnblogs.com/yqpy/p/11387928.html