How does git upload local code files to the git warehouse [detailed explanation with pictures and text]

Code cloud creates warehouse and submits for the first time

Git official address : https://git-scm.com/

first step

Insert image description here

Step 2

  • You can enter the current folder of the GIT folder and then CMD to enter the DOS interface and call GIT, or you can use the following method

Insert image description here

third step

Main commands:

  1. git init (initialize the warehouse)

  2. git add . (The . here means adding all files, you can also customize them)

  3. git commit -m 'Added comment information'

  4. git remote add origin ‘url’

  5. git push -u origin master

Insert image description here

Second submission

Main commands:

  1. git pull (pull online code, generally used when multiple people develop, if personal development can be submitted directly, the command can be omitted)
  2. git add . (Add all files to the git staging area)
  3. git commit -m 'comment information' (the contents of the staging area are added to the local warehouse, which is actually used to add comment information)
  4. git push -u origin master (Submit code to the remote warehouse, if it is the default master branch, you can also use it directly: git push)

Secondary command
git status (placed before git add, used to view changed files. When using VScode to write code, the modified file will also appear with a dark yellow capital after the file name: M)

Insert image description here

at last

Refresh the warehouse to see the uploaded code files! ! ! !
When submitting for the first time, if you need to fill in the username, email, and password here, just enter them normally. If the username and password are incorrect, you can try changing the username to the registered email. If they are not correct, the password, username, and password may be wrong. , can be modified or queried in the following ways

In addition, there will be corresponding commands below the newly created warehouse to help upload code to the warehouse. You can also refer to the command used to push the project to the warehouse. If the warehouse address changes during the second submission, you do not need to enter the account password. Use three commands to directly submit and
view user information.

用户名: $ git config user.name 
邮箱:$ git config user.email
密码:$ git config user.password  

Modify user information

用户名:$ git config --global --replace-all user.name "要修改的用户名"
邮箱: $ git config --global --replace-all user.email"要修改的邮箱"
密码:$ git config --global --replace-all user.password "要修改的密码"

Other commonly used git commands

查看修改状态:git status
拉取远程仓库代码:git pull
克隆远程某分支上的代码:git clone -b 分支名称 http://xxx.git
合并分支到主分支:git merge 分支名称
创建新分支:git branch 新分支名
删除分支:git branch -D 分支名
查看分支:git branch
分支切换:git checkout 分支名称
查看记录:git log
查看地址:git remote -v
强制合并代码(用于当前版本和历史提交版本不一致的情况):git pull origin 分支名--allow-unrelated-histories
本地代码覆盖远程分支代码:git push -f --set-upstream origin 分支名

Guess you like

Origin blog.csdn.net/weixin_51033461/article/details/119997189