# Cloning project
git clone url: cloning project to a local folder
# Create a branch
git branch xxx: branch code copies the main branch, to switch back to the main branch of the main branch will not affect the code in the modified code branch
# View branch directory
git branch: Check the local branch warehouse
# View remote repository branch directory
git branch -a: get a list of all the branches of a remote repository
# Check branch or main branch of the modification information
git status
# Submitted to the branch cache
git add:. submit code to the local repository cache
# Submitted to the local branch warehouse
git commit -m "xxxxxxx": submit code to a local warehouse
Switching between branches #
git checkout master or branch name
(but I did not project to create a new branch of habit, are modified directly in the main branch down the clone project code, and then later directly to the main branch of the local branch pushed to the remote repository)
(in order to protect the project the main branch are not recommended to be pushed to the remote repository's master then master merge pushed through a remote repository branch)
# Check the remote repository variable name
git remote -v: remote repository variable name is pushed to the warehouse in order to determine which (clone down when usually the default is origin)
# Push the local repository to the remote repository branch branch
git push origin local branch warehouses name: custom remote repository branch name (gitlab provide a view window merge code, interested can inquire about the imperative of git merge)
# Download remote warehouse branch in the local project (two ways)
git repository Checkout remote branch name (you can first get all the remote repository branch name with Branch-A git)
git clone a remote repository branch name -b remote repository address (which is recommended species)
git clone a remote repository branch name -b remote repository address new folder name (you can create folders to the code)
# Ignore file has been submitted (because after submitting the documents .gitignore rule is invalid)
git RM -f file to be ignored (by deleting files reconstruct the file achieved)
## Supplementary Information section
# Initial push to a remote repository project
git remote add origin address of a remote repository
git push -u origin branch name
# Delete the local branch
git branch -D local branch name: delete the local branch
# Delete remote repository branch
git push origin (blank): remote repository branch name: Blank spaces in part, it indicates a push to empty the contents of the branch.
# Roll back to a previous version of
git reset - hard head ^
# Enter global git-mail account
git config -global user.email "Email Address": Set the git-mail address
# Enter the global user name git
git config -global user.name "username"
# Check the user name
git config user.name
# Ssh key settings
ssh-keygen -t rsa (no need to enter the mailbox, as is already the default, and then enter several times to know to generate ssh key file, and then save the file to find the ssh key string to gitlab account)