git answers sorting

Source: Internet
Author: User

1.git Common Commands

First clear: Git has workspaces, staging area, repositories, workspaces are directories that can be seen on your computer

To create a warehouse:

Git init Newrepo, using our designated directory as the Git repository (after initialization, a directory called. Git will appear in the Newrepo directory, and all of the data and resources that git needs are stored in this directory)

Git init (A. Git directory is generated in the current directory when the command finishes, but this is an empty repository that can be added to the repository via git add + filename or git add +).

Git add + file name files are added from the local workspace to the local staging area (or let git track) (git add +.) to add all files from the current directory to the local staging area

git commit-m "xxx" (Git commit file1 file2-m "xxx") to add files from local staging area to the local warehouse area,-M followed by the instructions for this submission

Remote sync:

Git remote: View all remote repositories (the original only shows the remote repository name, Git remote-v the corresponding address)

Git remote add +str+url: Add a repository, STR is the name of the remote repository (or associated with a remote repository, or it can be automatically linked directly after cloning)

GIT remote show + remote Repository name: View details of a remote repository

git fetch, git pull

git push [remote-name] [branch-name]: Upload locally specified branch to remote repository (git push [remote]--all push all branches to remote repository) (unlike pull, will not merge, will only upload to remote your branch)

Git push origin--delete + branch name: Delete Remote Branch

Delete:

RM: Just deleted physical files and did not delete them from Git records

git rm: When we need to delete 暂存区 or 分支 on the file, the workspace also does not need this file, you can use

git rm--cached: When we need to delete 暂存区 or 分支 on the file, but local also need to use, just do not want this file is version controlled, can use

Intuitively, git rm deleted files, and when executing git commit-m "abc" commits, it automatically submits the action to delete the file. and the RM command to delete files directly, the simple implementation of Git commit-m "ABC" Commit, will not delete the file to submit the operation, you need to execute a commit, add a-a parameter, that is, RM Delete, you need to use Git commit-am "abc" Submission will not commit the deletion of the file.

Generally run out of git RM this operation, all git commit-m "xxx", one is to update the warehouse is to do a description

Display Information command:

git diff filename: compare workspaces and Staging area

git diff--cached FileName: Compare staging area with the latest local repository

git diff HEAD FileName: Compare workspaces and latest versions

Https://www.cnblogs.com/chenfulin5/p/8674565.html

Git status: See the current state of the GIT local repository 69544038

Changed but not updated: We have changed the SERVER.C but we have not updated the snapshot, we should execute git add at this time

Changes not staged for commit:

Changes to be committed: Indicates that our changes are ready, can be submitted at any time, we just need to commit with the git commit command.

untracked files:  表示没有被跟踪

git log: View git verbose logs, including different versions of Commit, time, author (previous configuration email and name will be useful here)

git log-[length]: How many logs are displayed

Label command:

git tag: List all tags

git tag [tag] [commit]: Create a new tag in the specified commit

 

Branch:

View all currently available branches: Git branch (Git branch, * No, * indicates the current branch)

Git branch is to view all local branches, Git branch-r is to view all branches of the remote, Git branch-a is to view all local and remote branches

$ git Branch  iss53* Master  Testing

New branch: Git branch + branch name

Delete branch: git branch-d + branch name

Switch branches: git checkout + branch name

Merge branch: git merge + branch name

  

Https://www.cnblogs.com/horanly/p/6603647.html

The difference between rebase and merge in 3.git

If some people have made changes to the remote origin, the general operation is to pull the remote code first, then the local merge, and then push

There is no difference between rebase and merge for two branches, but rebase is cleaner because the log hisitory is linear, but the commit does not necessarily follow the date, but the local commit is always behind. History becomes more complex after merge, but commits are sorted by date 24743751

Merge, rebase principle: 7554489

4. Local and remote repo name not the same how to solve?

git remote addincrease the remote repository by command.
git remote add origin **/bbb.git

https://segmentfault.com/q/1010000007848161?_ea=1472359

What is the difference between git pull and fetch merge ? What are the two commands that git pull equals?

Pull is the equivalent of git fetch and git merge, which is to update the remote repository's code to the local repository and then merge the content into the current branch. git fetch: The equivalent of getting the latest version from remote to local, not automatically merge
Git Fetch Origin remote branch: local branch   #origin是远程主机名
Git merge: Merge content into current branch git pull: equivalent to getting the latest version from remote and merging to local
Git pull < remote host name >< remote Branch name >:< local branch name >

79558622

What is the difference between 13.git merge and git merge--no--ff

Git merge–no-ff can save your previous branch history. Better view of merge history, and branch status.

Git merge does not display feature, leaving only a single branch record.

47419069?locationnum=10

81020370

Https://www.cnblogs.com/hechao123/archive/2017/02/12/6390359.html

Tell me about the difference between Reset and revert .

Revert is overwriting an old mistake with a new commit commit,reset is to return all commits after the wrong commit. Revert the commit of a commit,reset fallback of an interval.

66973734

80506041

19.git commit A problem, modify the commit with what command?

72948722

Http://www.softwhy.com/article-8492-1.html

git Amend: You can either modify the last commit submission or modify the last committed file

20.git is there a way to adjust the order between commits?

Can: http://www.softwhy.com/article-8639-1.html

But adjusting the order of commits is prone to conflict and error.

The difference between 31.fork and clone

Fork: A remote, server-side copy of a storage repository, fork is not a git category.
Clone: is a local copy of a remote repository. When cloning, you are actually copying the entire storage warehouse, including all the history and branches.

git answers sorting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.