This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11008|Reply: 2

The git version control tool is logged in to github

[Copy link]
Posted on 2/13/2017 10:19:29 AM | | | |


Step 1: To use GitHub The first step is to register a GitHub account. After that, you can create a repository (free users can only create a public repository), create a new repository, fill in the name and create, and then some repository configuration information will appear, which is also a simple tutorial of git.
Website: https://github.com

Step 2: Install the git version control tool first, and then install, install it directly in the next step!
Download Address:
Tourists, if you want to see the hidden content of this post, pleaseReply


Step 3:

Let's first find a place to store the local repository on the computer's hard drive, for example, we set up the local repository under the C:\project\MyProjects\AutoIndexNetScript folder

Go to the AutoIndexNetScript folder and right-click the operation as follows:

1) Right-click on Git Init Here in the local repository, and an additional .git folder will appear, which means that the local git has been successfully created. Right-click Git Bash to enter the git command line.

Execution:



behindyour_email@youremail.comYour email address instead. My email ishelp@itsvse.com, which is also the email address registered on github:



Click Enter directly to explain that the ssh key will be generated on the default file id_rsa.

Then the system asks you to enter a password, and directly press enter to indicate that there is no password

When the password is repeated, it is also directly entered, and then it prompts you that the shh key has been successfully generated.


Then we go to the prompted address under the address to view the ssh key file. The address of my computer is C:\Users\itsvse\.ssh, where itsvse is the name of my computer

Open id_rsa.pub and copy the key inside. The key inside is a pair of incomprehensible characters and numbers, don't worry about it, just copy it.



Go back to the github website, go to Account Settings, select SSH Keys on the left, Add SSH Key,

Or go directly to: https://github.com/settings/keys

Fill in the title and paste the key.


2) Verify that it is successful, enter it under git bash


Enter will see: You've successfully authenticated, but GitHub does not provide shell access. This means that you have successfully connected to github.

$ ssh -Tgit@github.com
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of know                                                                                                                n hosts.
Hi itsvse! You've successfully authenticated, but GitHub does not provide shell                                                                                                                 access.







Previous:Test posting to gain relevant experience.
Next:git push failed to push some refs to git
Posted on 2/13/2017 10:26:14 AM |
Learned thank you landlord
 Landlord| Posted on 2/13/2017 10:55:36 AM |
Git command

View, add, submit, delete, retrieve, reset modified files

git help <command> # shows the help of the command

git show # shows the content of a commit git show $id

git co -- <file> # discard workspace modifications

git co . # Ditch workspace modifications

git add <file> # commits working file changes to the local staging area

git add . # Submit all modified working documents to the staging area

git rm <file> # delete the file from the repository

git rm <file> --cached # deletes files from the repository, but not files

git reset <file> # restore from staging to working files

git reset -- . # Restore from staging to working files

git reset --hard # reverts to the state of the last commit, i.e. discards all changes made this time since the last commit

git ci <file> git ci . git ci -a # merge git add, git rm and git ci and other operations together to make git ci -am "some comments"

git ci --amend # modify the last commit record

git revert <$id> # reverts the state of a commit, and the restore action itself also creates a subcommit object

git revert HEAD # to restore the state of the last commit

Look at the file diff

git diff <file> # compare the current file and the staging area file difference git diff

git diff <id1><id2> # compare the difference between two commits

git diff <branch1>.. <branch2> # Compare between two branches

git diff --staged # compare staging and repository differences

git diff --cached # compares staging and repository differences

git diff --stat # just compares statistics



View the submission history

git log <file> git log # View the file for each commit record

git log -p <file> # to see the diff of each detailed modification

git log -p -2 # See the diff of the last two detailed changes

git log --stat #查看提交统计信息

tig
On Mac, you can use tig instead of diff and log, brew install tig


Git local branch management
View, switch, create, and delete branches

git br -r # to see the remote branch

git br <new_branch> # to create a new branch

git br -v # to see the last commit information for each branch

git br --merged # to see branches that have been merged into the current branch

git br --no-merged # to see branches that have not yet been merged into the current branch

git co <branch> # switch to a branch

git co -b <new_branch> # to create a new branch and switch to the past

git co -b <new_branch> <branch> # creates a new new_branch based on branch

git co $id # checkout a history commit record, but there is no branch information, and switching to another branch will be automatically deleted

git co $id -b <new_branch> # Checkout a history commit record and create a branch

git br -d <branch> # delete a branch

git br -D <branch> # Force deletion of a branch (need to be forced when an unmerged branch is deleted)


Branch merge and rebase

git merge <branch> # merge branches into the current branch

git merge origin/master --no-ff # Don't fast-foward merge, this will generate a merge commit

git rebase master <branch> # rebase master to branch, equivalent to: git co <branch> && git rebase master && git co master && git merge <branch>


Git patch management (convenient for development synchronization on multiple machines)

git diff > .. /sync.patch # to generate the patch

git apply .. /sync.patch # patch

git apply --check .. /sync.patch #测试补丁能否成功



Git staging management

git stash # staging

git stash list # lists all stashes

git stash apply # restore staged content

git stash drop # delete staging area

Git remote branch management

git pull # grab all branch updates from the remote repository and merge them locally

git pull --no-ff # Grab all branch updates of the remote repository and merge them locally, don't fast forward the merge

git fetch origin # Fetch remote repository updates

git merge origin/master # merge the remote main branch into the local current branch

git co --track origin/branch # Track a remote branch to create the corresponding local branch

git co -b <local_branch> origin/<remote_branch> # creates a local branch based on the remote branch, the function is the same as above


git push # push all branches

git push origin master # push the local main branch to the remote main branch

git push -u origin master # Push the local primary branch to the remote (created if there is no remote master branch to initialize the remote repository)

git push origin <local_branch> # to create a remote branch, origin is the remote repository name

git push origin<local_branch>:<remote_branch> # Create a remote branch

git push origin :<remote_branch> #先删除本地分支(git br -d<branch>), and then push to delete the remote branch



Git remote warehouse management

git remote -v # to see the remote server address and repository name

git remote show origin # to check the remote server repository status

git remote add origin git@ github:robbin/robbin_site.git # Add the remote repository address

git remote set-url origin git@ github.com:robbin/robbin_site.git # Set the remote repository address (to modify the remote repository address) git remote rm <repository> # Delete the remote repository


Create a remote warehouse

git clone --bare robbin_site robbin_site.git # Create a version-only repository with a project with versions

scp -r my_project.git git@ git.csdn.net:~ # Upload the pure repository to the server

mkdir robbin_site.git && cd robbin_site.git && git --bare init # Create a pure repository on the server

git remote add origin git@ github.com:robbin/robbin_site.git # Set the remote repository address

git push -u origin master # first commit by the client

git push -u origin develop # commits the local develop branch to the remote develop branch for the first time, and tracks

git remote set-head origin master # Set the HEAD of the remote repository to point to the master branch



You can also command set up tracking remote libraries and local libraries

git branch --set-upstream master origin/master

git branch --set-upstream develop origin/develop
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com