[Turn] git configuration https and ssh password-free login commands for common operations

Original Address: https://www.cnblogs.com/cxx8181602/p/11125539.html

 

git configuration https and ssh password free

A. Distinction https clone and ssh clone

Different clones in different ways resulting in parity mode, the corresponding free secret embodiment are not the same. 
https by account passwords to remember Bintang, ssh key verification generated by Bintang. Usually use ssh check.

 

Free Density Method two .https

Setting Configuration .git / config

git config --global credential.helper store
[credential]  
    helper = store

After you enter a second time will remember the account password account password.

 

Free Density Method three .ssh

Configuration information

git init

git config --global user.name 'username' 

git config --global user.email 'users' mailboxes'

Execute commands to generate public and private keys:

ssh-keygen -t rsa

Press Enter to 3 are generally not directly write directly enter empty

Check the implementation of public-key commands:

cat ~/.ssh/id_rsa.pub

Windows file location:

 

 

github add your ssh steps:

 

clone project get:

git clone [email protected]: 'Project url'

 

 

git common operations command

Submit these steps:

git status to view the status 
git add. add all files modified 
git status to view the status 
git commit -m 'remark information' add notes 
git push origin branches were committed to the branch

Branches merge master:

git checkout master cut to the master branch 
git pull origin master pulling master 
Git Merge branch name Origin combined merging branches need 
git status check the status of 
git push origin master push master

 

--git local project code uploaded to a remote warehouse operations:

Initialization: 
git the init

Local first installed git, configure basic information: 
git config -, Ltd. Free Join user.name 'username' 
git config --global user.email 'users' mailboxes'

Local warehouse and associated remote repository: 
git the Add Remote Origin 'project url'

updates, and make sure there is no conflict with remote warehouse code:
git pull --rebase Origin Master

copy the project to, ready to upload at a local git directory.

Operating submitted master steps:
git the Add.
Git Status
git the commit -m 'remarks information'
git the Push Origin master -f for the first time, forced to submit master branch. (Submit best not to use later!)

 

- File directory operations command

mkdir * * Create an empty directory refers to the directory name 
pwd displays the current directory path. 
* cat * View file content 
git rm * delete files **

--git initialization

git init becomes the current directory git repository, generate hidden .git file. 
git remote add origin url to content pushed to the local repository GitHub repository. 
git clone git@url/test.git library clones from a remote 
git add * x add files to the staging area to go. 
git commit -m "*" submission -m back is a comment.

 --git clone branch

git clone xxx.git most straightforward command 
git clone xxx.git "specified directory" clone to a specified directory 
git to create a new branch instead of the default Origin HEAD (master) when clone clone -b branchname xxx.git

- View command

git status to view the status of the warehouse 
git diff * View X Files modify the content of those    
git log to view the history 
git reflog view the history of the version number id (record your every command, whether or not submitted) 
git log --pretty = oneline if the information the amount can be much better display list

- version rollback

git reset -hard HEAD ^ fall back to the previous version 
git reset --hard HEAD ~ If you want to roll back to the first of several third version, use the RESET -hard the HEAD ~ 3 git 
git a fallback to the RESET --hard 057d a specific version number

 - undo changes

git checkout file-name restore a file has been modified (modifications withdraw uncommitted): 
git revert to modify the HEAD Revert last submitted: 
git Revert to restore the commit-specific version of the above mentioned id modification

- Branch Management

View all git branch local branch 
git branch -a view of all remote branch 
git branch name to create a branch 
git branch -d dev delete dev branch 
git push origin --delete dev dev delete remote branch 
git branch -m dev develop rename branch 

git checkout -b dev dev branches create and switch to the dev branch 
git merge dev on behalf of the current branch merging branch dev 
git push origin zyf-dev the current branch Xinjiang zyf-dev pushed to a remote database (not to branch is remote repository this will establish a new branch) 
 
git Checkout - * XX to withdraw all files modified in the workspace. 
git checkout master switch back to the master branch 
git push --set-upstream origin dev commit changes and create a remote branch dev

--tag related operations

git tag lists all the tag 
git tag name to play light tag name 
git tag -d delete the local name tag 
git the Push Origin --delete delete the tag name tag remote 
git show name tag to view information 
git push origin name tag will be submitted to the Remotely

- hidden files

git stash the current job hiding Once after recovery site continue to work 
git stash list to view all the hidden files list 
git stash apply recover hidden files, but the content does not remove 
git stash drop deleted files 
git stash pop to recover files at the same time also delete files

- View information about the remote repository (git remote usage)

git remote viewing remote database information 
git remote -v view the remote database details 
git remote add name url add a remote repository 
git remote rename oldname newname rename warehouse 
git remote rm delete warehouse

- the remote to the local branch pulled

Method a: git checkout -b local branch name x origin / remote branch name x 
Second way: git fetch origin remote branch name x: x local branch name

--git pull operation

git pull action command is to retrieve a branch update the remote host, and then combined with the specified local branch, the basic format is as follows. 
$ Git pull <remote host name> <remote branch name>: <local branch name> 
  
to retrieve origin host next branch and the local branch of the merger master, takes on the form below so 
$ git pull origin next: master 
  
If the remote branch is the combined current branch, the portion of the colon may be omitted. 
$ Git pull origin next 
  
command above said retrieved origin / next branch, and then merged with the current branch. In essence, this is equivalent to do first git fetch, do git merge. 
Origin git FETCH $ 
$ git Merge Origin / the Next 
 
in some cases, Git automatically between the local branch and a remote branch, to establish a relationship tracking (tracking). For example, when git clone, the 
same name as the local branches of all branches of default remote host, a tracking relationship, that is, the local master branch automatic "track" origin / master branch. 
Git also allows the track to establish relationships manually. 
git branch --set-upstream master origin / next 

upper branch command specifies master tracking origin / next branch. If the current relationship between the presence of trace branch and remote branch, git pull will be omitted remote branch name. 
$ Git pull origin

Guess you like

Origin www.cnblogs.com/exciting/p/11773263.html