Local projects related to remote git repository

Local projects related to remote git repository

The scene is this: Create a new project on gitee-code, gitee will help you project initialization, after initialization will generate a default documentation and gitignore files according to your choice. This time you can copy it addresses the project, the local project preparation and associated together.

The expansion of this scene, in fact, is a project associated with any remote git repository together process.

Associate completely blank project

First, speak a simple scenario, if we do not generate new projects when any initialization file, we need to do is to local projects and empty warehouses associate command in this case is:

#git initialize
git the init
# Set remote address
git remote add address
# added to all the documents git version management means that all files in the current folder into the version management
git the Add.
# submit written comments file using -m
git commit -m "comment"
# pushed to the remote branch
git push

Executing the above operation, the project is associated with the remote git repository together, can be used normally, go git project page you can see the code just submitted

There are documents associated with the project

Then consider the situation began to say most, is the remote warehouse has been documented, this time you perform the above steps is not possible, because of the need to update the remote repository file down first. Proceed as follows

#git initialize
git the init
# Set remote address
git remote add origin address
# to obtain the contents of the warehouse master remote branch
git pull Origin master
# the current branch is set as a remote master branch
git branch --set-upstream-to = origin / Master Master
# will be added to all files git version management means that all files in the current folder into the version management
git the Add.
# submit written comments file using -m
git the commit -m "comment"
# pushed to the remote branch
git push
this operation on it.

Setting warehouse level user name and mailbox

Git sometimes need to use multiple accounts, configure multiple user names and passwords you need a corresponding, configuration-related command git git config

# All your current configuration
git config -l
execute this command will enter a profile page, using the vim editor launch command to exit: wq

# Configure global level, if there is no special configuration repository level, the default read this configuration
git config --global user.name "name"
git config --global user.email "Email"

# Warehouse-level configuration, general configuration of a project once
git config user.name "name"
git config user.email "Email"

text: https: //blog.csdn.net/vi_error/article/details/80608793

Guess you like

Origin www.cnblogs.com/sweeeper/p/11249655.html