Basic configuration (user name and email)
git config --global user.name xxx
git config --global user.email [email protected]
Copy the code
Create a key (the generated key is stored in the ~/.ssh directory by default)
ssh-keygen -t rsa -C "[email protected]"
Copy the code
All press enter
Initialize the warehouse and operations
Git add [filename] git commit -m git status Compare two files) git add [file name] | | git commit - a - m/instructions regarding the submission (if the text file to change, Will change the file into the buffer | | in the git log buffer and prices) submitted (see instructions) git reset - hard head ~ [N] (return to the first N version) git reset - hard [commit id] (back to commit Git reflog git reflog git reflog git reflogCopy the code
Undo modify
Git checkout --[filename] git checkout --Copy the code
Readme. TXT has not been put into the staging area since the modification. Now, undo the modification and the version library exactly the same state. One is that readme.txt has been added to the staging area and then changed, and now undoing the changes will return to the state after it was added to the staging area. Return the file to the state it was at the last Git commit or git add
Delete operation
Git rmCopy the code
You can either delete it directly in a Windows window or use the command to delete it, but this is a workspace deletion, not yet in the repository.
Commit after deletion
Git commit -mCopy the code
If you accidentally delete the wrong file, don’t be afraid, sister will teach you
Git checkout --[filename] git checkoutCopy the code
Flush ignored files
Git rm -r --cached.Copy the code
Remote warehouse
Git remote add git remote rm origin git remote rm origin Git push -u origin master -u origin master git push -u origin master It also associates the local master branch with the remote master branch, which can be simplified for push or pull later. Git push [remote repository name] [branch name] Git Clone is a copy of the entire Git project, including the logs and branches of the git project. Git pull is equivalent to Git fetch and Git merge. This means downloading files from a Git project remotely and merging them with a local branch. Git branch git checkout -b git branch -b git branch -b git branch -b Git branch -d (delete branch)Copy the code
Adding upstream branches
Git remote add upstream git [git path] git remote -v Check whether the configuration is successful. Synchronous fork, fetch branch and commit point from upstream repository, commit to local master, Upstream /master git fetch upstream/master git fetch upstream This completes synchronization without losing local changes. Git push origin master git push origin master git push origin master git push origin masterCopy the code
The above is a personal summary, if there is any mistake, please point out thank you! Sister code word is not easy, brush to point a praise yao yao!