• git全局设置
    git config --global user.name "xxx"
    git config --global user.email "xxx"
  • 创建git仓库
    1)进入项目根目录
    git init

    2)添加到本地仓库
    git add .

    git commit -m "xxxx" 提交信息

    3)从远程获取最新版本并merge到本地
    git pull origin master

    4)提交本地分支到远程分支
    git remote add origin https://gitee.com/tahara/git-... git服务器上创建一个仓库

    git push -u origin master
  • 在提交过程中,切记要先pull代码,否则可能报出

    ! [rejected] master -> master (non-fast-forward)
    error: failed to push some refs to 'https://gitee.com/tahara/git-...'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    出现这个问题是因为gitee中的文件不在本地代码目录中,可以通过如下命令进行代码合并,之后在提交
    git pull --rebase origin master

  • 若已有仓库
    git remote add origin https://gitee.com/tahara/git-test.git
    git push -u origin master