Git configuration:
git config--global user.name "Tina Gao"
git config--global user.email "[Email protected]"
After executing the above command, a. gitconfig file will be created in the home directory to view the contents: Cat ~/.gitconfig
Clone a repository: Git clone http: ....
To initialize a new repository:
mkdir Project
CD Project
Git init
To create a file:
Touch file1 file2 File3
echo "Test" >> file1
echo "Test" >> file2
echo "Test" >> file3
To view the status of the current git repository:
git status
Add the untracked file to the buffer using the git add command:
git add file1 file2 file3
See which files in the cache are modified (diff comparison content):
git diff--cached
Submit to local repository: Git commit-m "Add 3 Files"
To synchronize the local warehouse to the remote server:
Git push Origin Master
A git repository can maintain many branches and create branches:
Git branch A
View the current branch: Git branch
Switch to branch: git checkout Master
After making modifications on branch A, merge to master:
git checkout Master
git merge-m ' Merge a branch ' a
Two branches when you change the same file, there is a conflict in the merge that causes the failure.
Undo Merge: Git reset--hard head^
View logs: Git log
Log statistics (print detailed commit records): Git log--stat
Format log as required: git log--pretty=short or git log--graph--pretty=oneline
Log sort: git log--pretty=format: '%h:%s '--topo-order--graph
Common commands for Git (i)