search

Home  >  Q&A  >  body text

What is the correct way to use git initialization of local warehouse?

For example, now in C:MyWork initialize this warehouse

git init

It should be right.

Then put the file in this directory.
At this time, I remembered that I should put it in git.

For example, the remote warehouse is https://git.oschina.net/kk/me.git
which has ReadME.MD


Next I should:

git remote add origin https://git.oschina.net/kk/me.git
git pull origin master
git push origin master

Are my steps correct? How to implement it? Just use git pull directly (no need to enter origin master)?

What is this for?

git branch --set-upstream-to=origin/master master

曾经蜡笔没有小新曾经蜡笔没有小新2772 days ago572

reply all(3)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:25:14

    git branch --set-upstream-to=origin/master masterThe function is to associate your local master branch with the remote origin/master branch. The purpose of the association is that if you operate under the local branch: git pull, git push, there is no need to specify the remote branch on the command line.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:25:14

    pull == fetch && merge is used to pull remote code and merge it.
    origin is the default name of the git remote repository, you can use another one
    master is the local master branch name

    If you are alone, the usual process is as follows:
    1. Initialize the local repository
    2. Add the remote repository address
    3. Write code
    4. git add somefile.xx Add the code you wrote to the repository or git commit Add the -a parameter
    5. git commit -m 'submit instructions' to submit your code
    6. git push origin master to push your code to the remote repository

    If multiple people collaborate, fetch and then merge before writing code or before committing. Or pull is fine. Submit after merging conflicts.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-02 09:25:14

    It is recommended to read Ruan Yifeng’s blog

    reply
    0
  • Cancelreply