instructions
The article directories
- instructions
-
-
- 1 GitHub workflow and introduction
-
- 1.1 Workflow
- 1.2 Program Introduction
- 1.3 GitHub Creates the main program repository
- 1.4 GitHub creates a developer repository
- 1.5 Submitting files on GitHub
- 2. Git installation and configuration
-
- 2.1 Preparations
- 2.2 install Git
- 2.3 Running Git to Register users
- 2.4 GitHub enables public key submission without encryption
- 2.5 Common Git Commands
- 3. Git local repository operations
-
- 3.1 Creating a Local Library
- 3.2 Adding files to the remote repository
-
- 3.2.1 Developer Workspace –> Developer Remote Repository
- 3.2.2 Developer GitHub Repository –> Main programmer GitHub repository
- 3.2.3 Main programmer merges request
- 3.3 Synchronize updates in the master programmer’s repository
-
- 3.3.1 Basic steps
- 3.3.2 Developer’s warehouse
- 3.4 Version Rollback
- 3.5 Common Errors
- 3.5.1 GitHub prompts you to enter a user name and password for each push
- 4. Use GitHub in the development environment
-
- 4.1 tortoiseGit(Windows) Simplifies operations
- 4.2 Using Git/GitHub in IDEA
-
- 4.2.1 Configuring Git and GitHub
- 4.2.2 Clone items from GitHub
- 4.2.3 Submit the project to local/remote warehouse
- 4.2.4 Update the project to the local repository
- 4.2.5 Using Git commands on terminals
- 4.2.6 Creating a Project and Uploading it to Github
- 4.3 Using Git/Github in Eclipse
-
- 4.3.1 Using Git to import projects in Eclipse
- 4.3.2 Synchronizing projects with Git in Eclipse
- 5. Gitlab use
-
- 5.1 IDEA Use Gitlab
-
- 5.1.1 Download the Gitlab plug-in
- 5.1.2 Logging In to Github to Search for a Token
- 5.1.3 gitlab idea Settings
- 5.1.4 Copy code address
- 5.1.5 Clone code
- 5.2 PyCharm uses Gitlab
-
- 5.2.1 Downloading the GitLab plug-in
- 5.2.2 Configuring the GitLab Server
- 5.2.3 Clone code source
- 5.2.4 Configuring Terminal Run the git command
- 5.3 HBuilderX uses GitLab
-
- 5.2.1 Git Plug-in Installation
- 5.2.2 Load the project from Gitlab
-
1 GitHub workflow and introduction
Github is a software source code hosting platform for version control through Git. In addition to Git repository hosting and basic Web management interface, Github also provides some convenient social common software development functions, namely the community function of the general population, including allowing users to track other users, organizations, software libraries, software code changes and bug comments, etc.
1.1 Workflow
The figure above shows git’s overall architecture, as well as the major commands associated with each part, and the parts involved.
-
A working directory is simply the area where you work. In the case of Git, this is the local working directory. The contents of the workspace will contain the content submitted to the staging area and the repository (the current commit point), as well as its own modifications.
Git add [filename] or [. (all)] : Commit the file from work to staging
Git pull: Update changes from remote repositories to local workspace
-
Stage area (also called index area) is a very important concept in Git. Is a transitional phase before we commit the changes to the repository. GIT’s help guide usually uses index to indicate the staging area. In your working directory there is a.git directory with an index file that stores the contents of the staging area. The git add command adds the workspace contents to the staging area.
Git commit -m “Commit description” : commit staging area to local repository
-
Local repository A repository of a version control system that exists locally. When the git commit command is executed, the staging contents are committed to the repository. Under the workspace there is a.git directory, the contents of this directory do not belong to the workspace, which is the repository data information, temporary storage related content is also in it. It is also possible to merge the remote repository copy *** into the local repository using merge or rebase. The figure only shows merge, but note that rebase can also be used here.
Git push: Commit a local repository to a remote repository
-
Remote Repository is basically the same as a local repository, except that one exists remotely and can be used for remote collaboration, while the other exists locally. Local and remote interaction can be realized through push/pull.
-
Git pull: Update changes from remote repositories to local workspace
Other commands:
-
Git remote -v: Check origin and upstream sources
-
Git remote add origin/upstream
-
Git fetch upstream: Fetch upstream commits and changes to the source repository
-
Git checkout Master
-
Git merge upstream/master
1.2 Program Introduction
-
Code: indicates the location of the code
-
Issues: discussion and bug tracking
-
Pull Request: Submit a request and conduct a code view
-
E.g. < 1 > I managed the project
To Do
: Task to be completedDoing
: In progressDone
: Done
-
Wiki: Project introduction, data repository (md format)
1.3 GitHub Creates the main program repository
- Create the main program repository
helloworld
The accountliuxinfengabc
, the properties forpublic
- The warehouse name
helloworld
Attributes,public
, visible to anyone, initialize onereadme
File.
- Creating a successfulGithub.com/liuxinfenga…
1.4 GitHub creates a developer repository
- Create a developer account
- To create a development account, apply for a new QQ email [email protected] to create an account.
- Log in to Github for email authentication
- To travel toGithub.com/liuxinfenga…
- The Fork is successful
- Go back to github.com and see the code for my Fork
1.5 Submitting files on GitHub
Github can perform simple operations, create files, submit files, how complex operations, need to operate in the local repository, submit.
2. Git installation and configuration
2.1 Preparations
- It-scm.com/ Download Git on its website.
- Sign up for GitHub (github.com/).
- Test repository github.com/liuxinfenga…
2.2 install Git
- Click Install, select the root directory and Git folder, and then Next-> Default install.
- After the installation is complete, go to the root directory, locate the Git folder, right-click the git-bash.exe executable, fix it to the toolbar, and click git-bash.exe to run it.
- Enter the command ls to view the file directory.
Normal installation complete!
2.3 Running Git to Register users
-
Set the user name and email address.
$git config –global user.name “Your name”
$git config –globaluser,email “[email protected]”
Set the username and email to be modified and submitted to the remote repository to be seen as the submitter, used in team development to identify the code author.
Git config user.name 2. Git config user.email Git config --global user.name "Your_username" git config --global user.email "Your_email"Copy the code
-
Type $git init to start Git.
2.4 GitHub enables public key submission without encryption
-
. Create/connect the primary repository.
-
Enter $ssh-keygen -t rsa [email protected]”Press Enter three times to generate the public key, find the id_rsa.pub file under C:\Users\ administrator. SSH, and open notepad to copy the public key. or
-
Create a new key on GitHub, customize the title, paste the public key, and save it.
- Select Settings
- Until you go to the SSH and GPS Keys menu, click New SSH Key
- Select Settings
- Copy the generated key
- Receive the email
2.5 Common Git Commands
-
File manipulation (same as Linux commands)
mkdir
File name: Create foldercd
Folder name: Go to the foldertouch
File name: Create a file
–git rm
The file name
-
Copy the warehouse
git init
: Initializes the Git repository locallygit clone
: Copies a warehouse to a local warehouse.git status
: View the current status
-
Submit information
Git add [filename] or [. (all)]
: Submits files from work to the staging areaGit commit -m
: Commits the staging area to the local repositorygit push
: Commits the local repository to the remote repository
#After committing changes from staging to the local repository using the Git commit command, the last step is to push the branch of the local repository to the corresponding branch on the remote serverGit push < remote hostname > < local branch name > < remote branch name >#For example git push origin master: refs/for/master: pushes the local master branch to the corresponding master branch on the remote host Origin. Origin is the name of the remote host. The first master is the local branch name and the second master is the remote branch name.
git push origin master
#If the remote branch is omitted, it means that the local branch is pushed to the remote branch with which it has a tracing relationship (usually with the same name). If the remote branch does not exist, it will be createdGit push origin: refs/for/master#If you omit the local branch name, you delete the specified remote branch, because this is equivalent to pushing an empty local branch to the remote branch, which is equivalent to git push origin -- delete master
git push origin
#If the current branch is traced to the remote branch, both the local and remote branches can be omitted and the current branch can be pushed to the corresponding branch of the Origin host
git push
#If the current branch has only one remote branch, then the host name can be omitted, such as git push. You can use git branch -r to view the remote branch name
Copy the code
-
Update warehouse information
git pull
: Updates changes from the remote repository to the local workspacegit remote -v
: Check origin and upstream sourcesGit remote add origin/upstream git address
: Add origin/upstream sourcegit fetch upstream
: Gets upstream source repository commits and changesgit checkout master
: Switch to mastergit merge upstream/master
: merges the remote master
Avoid crawler reading
This article is from the training materials of computer Science and Technology College of Shandong Jianzhu University. In order to let more people know this very detailed information, but also to help more people, with the help of this platform to share with you.
It was completed by Professor Liu Xinfeng, cheng Honghao, the brothers from the R&D department of Jicheng Energy Co., LTD, and other students from Shenshen Studio. Thank them. Training materials are open source: github.com/liuxinfenga… This article is open source address: github.com/liuxinfenga… In this paper, CSDN address: truedei.blog.csdn.net/article/det…
3. Git local repository operations
1. This article assumes: the main programmer GitHub address: github.com/liuxinfenga…
2. Developers log in from the main programmer GitHub (github.com/liuxinfenga…
Developer GitHub address: github.com/github-deve…
- Get project address
Github.com/github-deve…
3.1 Creating a Local Library
Git init is mainly used to initialize an empty Git local repository. After you run the preceding command, the current directory automatically generates a hidden git folder, which is the git version library.
Use method: Go to an empty folder, open Git Bash command window and enter
- git init
- git clone Github.com/github-deve…
- Download the results
3.2 Adding files to the remote repository
After modifying the local content, you need to go to the folder to perform Git operations
git add .
:. Indicates the current folderGit commit -m
git push
: # Push to developer repository
3.2.1 Developer Workspace – > Developer Remote Repository
Git bash git bash
cd test
# enter foldertouch one.js
Create a filegit add one.js
Add a file to submitgit status
# check statusGit commit -m
Commit to local repositorygit push
Push from local repository to remote repository
At this point, I am only in my GitHub repository, not yet in the main programmer’s GitHub repository
Git push code on Github prompts for username and password
Git clone github.com/yychuyu/lin…
Git clone [email protected]:yychuyu/linux-system-programming
The solution is as simple as changing the HTTP mode to SSH mode.
1 Check the current mode:
git remote -v
2 Change the HTTP mode to SSH. First remove the old HTTP origin:
git remote rm origin
3 Add a new SSH origin:
git remote add origin [email protected]:yychuyu/linux-system-programming.git
4. Check if any changes are successful:
git remote -v
Git push is not required to push the code directly after the change, so you need to set the upstream branch to track, and at the same time, you will automatically execute a git push command, so you do not need to input the username and password.
git push --set-upstream origin master
3.2.2 Developer GitHub Repository — > Lead programmer GitHub repository
- Log on to Github, enter the project,
Click the New pull request command
.
- Submit via Create pull Request, submit to lead programmer, notify review
3.2.3 Main programmer merges request
- The lead programmer logs in to Github to view the pull request
- Click FileChanged to view the changes, review them, and merge them
This updates from the developer’s GitHub to the repository lead programmer in his original fork
3.3 Synchronize updates in the master programmer’s repository
Note: The developer warehouse and the main programmer’s warehouse are two independent warehouses, the main programmer’s warehouse does not automatically update to the developer’s warehouse. Proactive updates are required.
3.3.1 Basic steps
git remote -v
: Check origin and upstream sourcesGit remote add origin/upstream git address
: Add origin/upstream sourcegit remote rm origin/upstream
# remove origin/upstreamgit fetch upstream
git checkout master
git merge upstream/master
git push
3.3.2 Developer’s warehouse
You can see that the developer’s repository hasn’t been updated yet.
-
Git remote -v: Check origin and upstream sources.
-
Origin means remote host (developer repository) and upstream means main programmer repository
-
Liuxinfengabc account login (primary programmer account)
D:\idea-work\zup-boot-org>git remote -v origin https://github.com/zonedaylab/zup-boot.git (fetch) origin https://github.com/zonedaylab/zup-boot.git (push) Copy the code
-
-
Add the main program repository address
git remote add upstream https://github.com/liuxinfengabc/helloworld
-
Git fetch upstream git fetch upstream
-
Git checkout master
-
Git merge upstream/master
-
Git push # push to developer remote repository.
At this point, the developer’s local library is fully synchronized with the lead programmer’s original repository. Git push: Git push: git push: git push: Git push: Git push: Git push: Git push: Git push: Git push: Git push
3.4 Version Rollback
Note: If errors are found after a version is submitted and you need to roll back the version, you can use the following method
Steps:
-
Git log
-
Git reset –hard
-
Git push -f #push to a remote repository
The rollback version is complete
Try the following commands when push fails
- git push origin master
- git push -f origin master
3.5 Common Errors
3.5.1 GitHub prompts you to enter a user name and password for each push
-
why
When we create a remote repository or clone project, we use HTTPS mode. HTTPS mode push does not save the user name and password. We need to change from HTTPS to SSH
-
Check the remote connection mode git remote -v
$ git remote -v
origin [email protected]:liuxinfengabc/https://github.com/liuxinfengabc/cultivate/cultivate.git (fetch)
origin [email protected]:liuxinfengabc/https://github.com/liuxinfengabc/cultivate/cultivate.git (push)
Copy the code
- Delete the origin
$ git remote rm origin
Copy the code
4. Configure the SSH mode
$ git remote add origin [email protected]:liuxinfengabc/cultivate.git
Copy the code
Avoid crawler reading
This article is from the training materials of computer Science and Technology College of Shandong Jianzhu University. In order to let more people know this very detailed information, but also to help more people, with the help of this platform to share with you.
It was completed by Professor Liu Xinfeng, cheng Honghao, the brothers from the R&D department of Jicheng Energy Co., LTD, and other students from Shenshen Studio. Thank them. Training materials are open source: github.com/liuxinfenga… This article is open source address: github.com/liuxinfenga… In this paper, CSDN address: truedei.blog.csdn.net/article/det…
4. Use GitHub in the development environment
4.1 tortoiseGit(Windows) Simplifies operations
TortoiseGit is a source client for an open Git version control system that supports Windows XP/Vista/Windows 7. This software has the same function as Git, but the difference is: Git is a command line operation mode, tortoiseGit interface operation mode, do not need to remember git related commands, can be directly operated, you can choose to install according to your own situation.
TortoiseGit download address: download.tortoisegit.org/tgit/
- Git commit operation. After modifying the file, right-click Commit, type Message, and click Commit to commit to the local repository.
- Git pull pulls server files. In the project folder, right-click and select TortoiseGit->Pull and click OK.
- Git push -> Git Push
If an exclamation mark appears in a file, the conflict must be resolved:
- 1. After clicking Close, you can directly click Yes in the pop-up window to check the conflict. You can also click Diff to see where the conflict occurs between the local warehouse file and the file on the server.
- 2. Double-click the conflict file in the window that is displayed to resolve the conflict.
- 3. After the conflict is resolved, delete unnecessary files generated in the directory and commit again.
New article:
Step 1: After adding a file to the repository, pull first, then you can see the difference between the file and the repository in diff
Step 2: Right-click -> Commit, select the file you want to commit, and click Commit
Step 3: Push the file
4.2 Using Git/GitHub in IDEA
4.2.1 Configuring Git and GitHub
- Set the git.exe path
The File – > Settings – > Version Control – > Git/lot
- Log in to your Github account
4.2.2 Clone items from GitHub
- File ->New->Project from Version Control
- Set the GitHub address and storage path
- Click the Clone
4. Cloning is complete
4.2.3 Submit the project to local/remote warehouse
- Git add
- To Commit the file, press VCS – >Git – >Commit Changes
See that the push has been successful
If you are updating to the main programmer’s repository, refer to the pull Request described earlier
4.2.4 Update the project to the local repository
What happens in idea if someone updates the warehouse?
All three places are fine
4.2.5 Using Git commands on terminals
The File – > Settings – > Tools – > Terminal – > Shell path
Alt +F12 to open the command window and run the following command as you would under Git bash:
- Git remote -v: Check origin and upstream sources
- Git remote add origin/upstream
- git fetch upstream
- git checkout master
- git merge upstream/master
- git push
4.2.6 Creating a Project and Uploading it to Github
Click on the Share
Click Add to upload the project to GitHub and create a repository named testJava if no repository exists
If the message “Successfully” is displayed, the creation is successful
4.3 Using Git/Github in Eclipse
4.3.1 Using Git to import projects in Eclipse
- Open the Git Repository window and click on the Add An Existing Local Git Repository to this View icon
- Select your local Git repository in Directory and select the Git repository Directory you want to import below
- Open the repository you are importing ->Working Tree, select the project you want to Import, right-click ->Import Projects…
- Adjust options and import projects
- Right-click the imported Project ->Gradle->Refresh Gradle Project
4.3.2 Synchronizing projects with Git in Eclipse
- Right-click project ->Team->Synchronize Workspace to go to the synchronization window
- Open the bi-directional red arrow file and merge the code. Right-click the file ->Mark asMerged
- Select the file you want to upload and right-click ->Add to Index/ Right-click on Unstaged Changes ->Add to Index
- Passage Ten (Antlized) Changes You can view the file to be submitted from Staged Changes, enter the Commit remarks and author in the Commit Message, and click Commit locally
- Pull updates files from the server
- Finally Push to the server
Avoid crawler reading
This article is from the training materials of computer Science and Technology College of Shandong Jianzhu University. In order to let more people know this very detailed information, but also to help more people, with the help of this platform to share with you.
It was completed by Professor Liu Xinfeng, cheng Honghao, the brothers from the R&D department of Jicheng Energy Co., LTD, and other students from Shenshen Studio. Thank them. Training materials are open source: github.com/liuxinfenga… This article is open source address: github.com/liuxinfenga… In this paper, CSDN address: truedei.blog.csdn.net/article/det…
5. Gitlab use
5.1 IDEA Use Gitlab
5.1.1 Download the Gitlab plug-in
5.1.2 Logging In to Github to Search for a Token
This configuration is not required in HTTPS
5.1.3 gitlab idea Settings
5.1.4 Copy code address
http://124.130.192.24:10015/liuxinfengabc/test.git
5.1.5 Clone code
5.1.6 Update the code
Error:
But the command line can:
5.2 PyCharm uses Gitlab
Basically the same as IDEA
5.2.1 Downloading the GitLab plug-in
5.2.2 Configuring the GitLab Server
5.2.3 Clone code source
- To obtain the code address, you first need to register an account and have code permissions
http://git.iesnengyuan.com/jianda/gisofflinemapsystem
Copy the code
- PyCharm Runs the Clone command
Go to the VCS menu -->Git-- >Git CloneCopy the code
- Enter a user name and password
5.2.4 Configuring Terminal Run the git command
ALT+F12 displays the terminal
5.3 HBuilderX uses GitLab
5.2.1 Git Plug-in Installation
1, open the tool – “plug-in installation
2. Install Git
5.2.2 Load the project from Gitlab
1, select file – “New -” project
2. Select File > Import > Git project > Enter address > import
This article is from the training materials of computer Science and Technology College of Shandong Jianzhu University. Deep Studio was founded by me in 2018, and I am also one of the main principals. In order to let more people know this very detailed information, but also to help more people, with the help of this platform to share with you.
It was completed by Professor Liu Xinfeng, cheng Honghao, the brothers from the R&D department of Jicheng Energy Co., LTD, and other students from Shenshen Studio. Thank them. Training materials are open source: github.com/liuxinfenga… This article is open source address: github.com/liuxinfenga… In this paper, CSDN address: truedei.blog.csdn.net/article/det…