git remote

 
    git remote # View the information of the remote library
    git remote -v # Show more detailed information
                            # Shows the address of the origin that can be crawled and pushed. If you don’t have push permission, you can’t see the push address    

    git push origin master # Push all local commits on the master branch to the remote repository.
                                          # When pushing, you must specify the local branch, so that Git will push the branch to the remote branch corresponding to the remote library

    git push origin dev # Push all local commits on the dev branch to the remote library

 

    It is not necessary to push local branches remotely. So, which branches need to be pushed and which do not?

    The master branch is the main branch, so it must be synchronized with the remote at all times; the
    dev branch is the development branch, and all members of the team need to work on it, so it also needs to be synchronized with the remote; the
    bug branch is only used to fix bugs locally , so there is no need to push to It's remote, unless the boss wants to see how many bugs you fixed every week;
    whether the feature branch is pushed to the remote depends on whether you develop it in cooperation with your small partner.


    git remote add <remote-name> <url> # Add a remote warehouse
        git remote add origin https://github.com/.git    

    # If you have not cloned an existing warehouse, and want to connect your warehouse to a remote server, use the above command to add, you can push your changes to the added server

    git remote rename demo test # rename
    git remote remove dev # delete a remote warehouse
    git remote rm test # delete a remote warehouse

    
    # Get data from remote warehouse:

    git fetch origin develop # Just get the data of the remote warehouse to the .git directory, not merge locally

    git merge origin/develop # Manually merge the acquired data of the remote warehouse to the current branch

    git pull origin develop # Get the data of the remote warehouse and automatically merge to the current branch, which is equivalent to the above two steps


    # Merge two different projects:
    --allow-unrelated-histories

    # Push the contents of the local warehouse to the remote library:
    git push (-u) demo develop (migrate from svn to gitlab, pay attention to the path, make sure the path is correct)


    Note: Since the remote library is empty, we added the -u parameter when pushing the master branch for the first time.

    Git will not only push the contents of the local master branch to the new remote master branch, but also associate the local master branch with the remote master branch.

    The commands can be simplified in future push or pull.

    
    The local branch from the remote branch checkout is called the tracking branch. A tracking branch is a local branch that has a direct connection with a remote branch.
    
    Enter git push in the tracking branch, and Git will infer by itself which branch of which server it should push data to. Conversely, running git pull in these branches will get all remote indexes
    
    and merge their data into the local branch.


    git push origin develop:test # Submit the local test branch as a remote develop branch
    git push origin :test # Delete the remote test branch, but the local   
    git push origin test:master # Submit the local test branch as the remote master Branch//It seems that only this sentence is written, and the remote github will automatically create a test branch
    git push origin test:test # Submit the local test branch as the remote test branch

Guess you like

Origin blog.csdn.net/xiaozhiwise/article/details/114262675