58 Mine Sweeping System APP Source++ Git Use and Basic Commands

Posted by terandle on Mon, 23 Sep 2019 10:09:02 +0200

Repository

There is a hidden directory in the workspace. Git, 58 Red Pack Mine Sweeping System developed by Wu Yan: I56 2227 micro 7887, this is not a workspace, but Git version library.

Git's version library contains a lot of things, the most important of which is the temporary area called stage (or index), the first branch master that Git created for us automatically, and a pointer to master called HEAD.

A git warehouse management project

git init    //Create a warehouse with a hidden directory under the project directory. git

git add file   //Submitted to temporary storage area

git add .  //Under the project directory, git add. can submit all modified and newly created data temporary areas

git commit -m "Explain information"      //Submit the contents of the temporary storage area to the current branch

git status      //View state

git diff file //Look at the file modification, git diff compares whether the file is different before git add

git diff --cached or git diff --cached //View the changes that have been temporarily added to the next submission

git log //view log

git log --pretty=oneline

git log --graph --pretty=oneline --abbrev-commit //View log charts

git log -p -2 //- The p option expands to show the content difference for each submission, while - 2 shows only the last two updates:

git reflog //Viewing all submitted log s, you can see the version number of each change for easy reference.

git reset --hard HEAD^ //Back to the previous version

git reset --hard HEAD^^ //Back to the previous version

git reflog //View Executed Commands

git checkout -- file //Back to the last modification

git checkout . //This command checks out all the modified files in the current directory from HEAD and restores them to their original state.

git reset --hard File number //Specify that you return to the file corresponding to the version number

git reset HEAD file //You can either return the version or the modification of the temporary area back to the workspace. Use HEAD to represent the latest version

git rm file   //Do delete the file from the repository, and then git commit

Revocation
Scenario 1: When you change the contents of a file in the workspace and want to discard the changes in the workspace directly, use the command git checkout -- file.

Scenario 2: When you not only change the contents of a file in the workspace, but also add it to the temporary storage area, you want to discard the modification in two steps. The first step is to use the command git reset HEAD < File > and then go back to Scenario 1. The second step is to operate according to Scenario 1.

Scenario 3: When an inappropriate modification has been submitted to the version library, you want to revoke the submission if you don't push it to the remote library, first use git reset - hard HEAD^
Creating a remote warehouse

1.git config --global user.name "Your Name"

2. git config --global user.email "email@example.com"

3.ssh-keygen -t rsa -C "youremail@example.com"    //Generate SSH Key, return all the way, use the default value, and find the. ssh directory in the user's home directory. There are two files, id_rsa and id_rsa.pub. These are the secret key pairs of SSH Key. id_rsa is the private key, which can not be leaked out. id_rsa.pub is the public key; login GitHub, open "Account settings" and "SSH Keys". Page: Then, click Add SSH Key, fill in any Title, and paste the contents of id_rsa.pub file in the Key text box.

4. git remote add origin Remote library URL //When the URL is SSH in gihub, add a new remote warehouse

5. git push origin master //First remote submission using git push-u origin master

6.git remote set-url origin Your remote address   // Setting up remote warehouse address

7.git remote add <shortname> <url>      //Add a new remote Git repository

 eg:git remote add pg https://github.com/paul/tic//pg is the name of the remote warehouse

8.git remote -v   //View Remote Warehouse

Delete remote warehouse

git remote rm origin //Delete remote Git repositories

git clone Remote library URL //Cloning a local repository, cloning engineering from a remote repository to a local computer

git remote //View information from remote Libraries

git remote show [remote-name] //View more information about a remote warehouse

git remote rename //To modify the abbreviation git remote rename pg pvul // rename pg pvul to pvul

git remote rm [remote-name] //Delete the specified remote warehouse

Branching operation

Git checkout-b dev // Create and switch to dev branch, called "dev"

Note: Watch out for uncommitted changes in your work directory and temporary area that may conflict with the branch you are about to check out and prevent Git from switching to that branch. The best way is to keep a clean state before you switch branches.

git checkout Branch name //Switching branches

git branch //View the current branch

git branch Branch name //Create branch

git merge Branch name //Merge the specified branch to the current branch

git branch -d Branch name //Delete branch

git branch -D Branch name //Delete branch

git branch --set-upstream-to=origin/dev dev //Specify the link between the local dev branch and the remote origin/dev branch, and set the link between Dev and origin/dev

git pull    //Get the latest updates submitted from the remote repository

git pull origin(Remote Warehouse Name) master(Branch name) //Automated grab and merge remote branches to the current branch

git push [remote-name] [branch-name]

git push origin --delete [branch-name] //Delete a remote branch

 

git merge --abort //Termination of merger conflicts

git merge --no-ff -m "Relevant instructional information" Branch name // - no-ff parameter to disable Fast forward

git stash // "Store" the current work site and continue to work after it is restored.

git stash list //View the work site

git stash pop //Restore the work site and delete the contents of the stash.

Rename the dev branch of the remote branch to deve branch as follows:

1. Delete the remote branch first: git push --delete origin dev

2. Rename local branch: git branch-m deve

3. Recommit a remote branch: git push origin deve

Label operation

git tag <name> //Put a new tag like git tag v1.0

git tag //Look at all the labels

git tag <name> commit id //Label the corresponding commit id. For example: git tag v0.9 f52c633

git log --pretty=oneline //You can see the label

git show <tagname> //View label information such as git show v0.9

git tag -d <tagname> //Delete labels, such as git tag-d v0.1

git push origin --delete tag <tagname> //Delete remote labels

git push origin <tagname> //Push a label to a remote location

git push origin --tags //One-time push all local labels that have not yet been pushed to the remote

Steps to delete remote Tags

1.git tag -d <tagname> //Delete local labels first

2.git push origin :refs/tags/<tagname> //Remove from remote

Multi-person collaboration model

First, you can try to push your own modifications with git push origin < branch-name >.

If the push fails, because the remote branch is newer than your local branch, you need to use git pull to try to merge first.

If there is a conflict in the merger, resolve the conflict and submit it locally; if there is no conflict or resolve the conflict, then use git push origin < branch-name > push to succeed.

Emphasis is laid on:

If a submission error occurs, you can git reset HEAD ^ go back to the workspace where you want to submit code, re-git add the desired file to the temporary area, then git commit-m "" commit, and then git push-f origin dev (branch name) / / override the remote branch.

Topics: Programming git ssh github