instructions

The article directories

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.

  1. 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

  2. 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

  3. 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

  4. 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

    1. To Do: Task to be completed
    2. Doing: In progress
    3. Done: Done
  • Wiki: Project introduction, data repository (md format)

1.3 GitHub Creates the main program repository

  1. Create the main program repositoryhelloworldThe accountliuxinfengabc, the properties forpublic

  2. The warehouse namehelloworldAttributes,public, visible to anyone, initialize onereadmeFile.

  1. Creating a successfulGithub.com/liuxinfenga…

1.4 GitHub creates a developer repository

  1. Create a developer account

  1. To create a development account, apply for a new QQ email [email protected] to create an account.
  2. Log in to Github for email authentication
  3. To travel toGithub.com/liuxinfenga…

  4. The Fork is successful

  1. 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

  1. It-scm.com/ Download Git on its website.
  2. Sign up for GitHub (github.com/).
  3. Test repository github.com/liuxinfenga…

2.2 install Git

  1. Click Install, select the root directory and Git folder, and then Next-> Default install.
  2. 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.
  3. Enter the command ls to view the file directory.

Normal installation complete!

2.3 Running Git to Register users

  1. 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
  2. Type $git init to start Git.

2.4 GitHub enables public key submission without encryption

  1. . Create/connect the primary repository.

  2. 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

  3. Create a new key on GitHub, customize the title, paste the public key, and save it.

    1. Select Settings

    2. Until you go to the SSH and GPS Keys menu, click New SSH Key

  1. Copy the generated key

  2. Receive the email

2.5 Common Git Commands

  1. File manipulation (same as Linux commands)

    • mkdirFile name: Create folder
    • cdFolder name: Go to the folder
    • touchFile name: Create a file

      git rmThe file name
  2. Copy the warehouse

    • git init: Initializes the Git repository locally
    • git clone: Copies a warehouse to a local warehouse.
    • git status: View the current status
  3. Submit information

    • Git add [filename] or [. (all)]: Submits files from work to the staging area
    • Git commit -m: Commits the staging area to the local repository
    • git 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
  1. Update warehouse information

    • git pull: Updates changes from the remote repository to the local workspace
    • git remote -v: Check origin and upstream sources
    • Git remote add origin/upstream git address: Add origin/upstream source
    • git fetch upstream: Gets upstream source repository commits and changes
    • git checkout master: Switch to master
    • git 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…

  1. 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

  1. git init
  2. git clone Github.com/github-deve…

  3. 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

  1. git add .:. Indicates the current folder
  2. Git commit -m
  3. git push: # Push to developer repository
3.2.1 Developer Workspace – > Developer Remote Repository

Git bash git bash

  • cd test# enter folder
  • touch one.jsCreate a file
  • git add one.jsAdd a file to submit
  • git status# check status
  • Git commit -mCommit to local repository
  • git pushPush 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
  1. Log on to Github, enter the project,Click the New pull request command.

  2. Submit via Create pull Request, submit to lead programmer, notify review

3.2.3 Main programmer merges request
  1. The lead programmer logs in to Github to view the pull request

  2. 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
  1. git remote -v: Check origin and upstream sources
  2. Git remote add origin/upstream git address: Add origin/upstream source
  3. git remote rm origin/upstream# remove origin/upstream
  4. git fetch upstream
  5. git checkout master
  6. git merge upstream/master
  7. git push
3.3.2 Developer’s warehouse

You can see that the developer’s repository hasn’t been updated yet.

  1. 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
  2. Add the main program repository address

git remote add upstream https://github.com/liuxinfengabc/helloworld

  1. Git fetch upstream git fetch upstream

  2. Git checkout master

  3. Git merge upstream/master

  4. 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:

  1. Git log

  2. Git reset –hard

  3. 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

  1. 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

  2. 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
  1. 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/

  1. Git commit operation. After modifying the file, right-click Commit, type Message, and click Commit to commit to the local repository.

  2. Git pull pulls server files. In the project folder, right-click and select TortoiseGit->Pull and click OK.
  3. 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
  1. Set the git.exe path

The File – > Settings – > Version Control – > Git/lot

  1. Log in to your Github account

4.2.2 Clone items from GitHub
  1. File ->New->Project from Version Control

  2. Set the GitHub address and storage path

  3. Click the Clone

4. Cloning is complete

4.2.3 Submit the project to local/remote warehouse
  1. Git add

  2. 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:

  1. Git remote -v: Check origin and upstream sources

  2. Git remote add origin/upstream
  3. git fetch upstream
  4. git checkout master
  5. git merge upstream/master
  6. 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
  1. Open the Git Repository window and click on the Add An Existing Local Git Repository to this View icon
  2. Select your local Git repository in Directory and select the Git repository Directory you want to import below
  3. Open the repository you are importing ->Working Tree, select the project you want to Import, right-click ->Import Projects…
  4. Adjust options and import projects
  5. Right-click the imported Project ->Gradle->Refresh Gradle Project
4.3.2 Synchronizing projects with Git in Eclipse
  1. Right-click project ->Team->Synchronize Workspace to go to the synchronization window
  2. Open the bi-directional red arrow file and merge the code. Right-click the file ->Mark asMerged
  3. Select the file you want to upload and right-click ->Add to Index/ Right-click on Unstaged Changes ->Add to Index
  4. 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
  5. Pull updates files from the server
  6. 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
  1. 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
  1. PyCharm Runs the Clone command
Go to the VCS menu -->Git-- >Git CloneCopy the code

  1. 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…