[Switch] git common problem handling

1. How does git avoid having to enter the user name and password every time it pulls or pushes?

git config --global credential.helper store
insert image description here
This command generates a booklet of account and password in your local, so that you don’t have to enter it every time (but you have to enter it once)

This command is common to windows and linux

2. How to check the current warehouse address?

Sometimes you need to check the address of the currently used git warehouse, such as sending it to colleagues or other developers for others to pull the code for use.

At this time, we only need to use the following command:

git remote show origin
insert image description here

3. Git cloning error fatal: unable to access 'https:XXX' failure: Connection was reset and slow cloning

git config --global http.postBuffer 524288000
insert image description here

4. What is the difference between Git Merge and Git ReBase?

Git Merge: This merging method is to merge the histories of two branches together. The current branch will not be changed. It will compare and cache the different files of both parties, generate a commit, and push it.

Git Rebase: This method of merging is often called "rebase". He submits the modification history, compares the commits of both parties, finds out the difference and caches it, and then pushes to modify the commit history.

5. We often modify some configuration files in local projects. These files generally record environmental information such as databases, redis, etc., and we don’t want these files to be displayed every time we execute git status. How should we operate?

Create a special .gitignore file in the root directory of the Git workspace, and then edit the ignored file names, and Git will automatically ignore these files.

6. When a similar (your-branch-is-ahead-of-origin-master-by-3-commits) situation occurs in GIT, how to deal with it?

(1) Method 1: git fetch origin
(2) Method 2 (the code is still required): git push origin
(3) Method 3 (the code is not required): git reset --hard origin/$branch
Reference:
https://blog.csdn.net/Thousa_Ho/article/details/73350703
https:/ /stackoverflow.com/questions/16288176/your-branch-is-ahead-of-origin-master-by-3-commits
You can execute it first git diff $branch origin/$branch to see the difference
[Remarks, first git log to see if there is any push commit , if not, use git reset --hard origin/$branch to overwrite to be the same as the remote warehouse, if there is, push first] (
4) git pull --rebase
(5) git pull origin cherryPick
Reference: https://blog.csdn.net/ u010383937/article/details/72901675

Guess you like

Origin blog.csdn.net/o0way0o/article/details/128893119