[Can’t use code sharing? Play with Git, keep up with the pace and get on the bus! 】

1. Install Git client

  1. Here we provide you with the Windows version of Git client and detailed installation documentation. Baidu Netdisk:

    https://pan.baidu.com/s/1CDu0Ke199pt3Ysv-QtWObA

    Extraction code: 8888

  2.  If it expires, please leave a message and contact me.

2. Register a code cloud account

  1. Open the code cloud website: https://gitee.com/

  2. Click register to submit information

picture

picture

3. Create a remote branch

Create a remote warehouse

picture

picture

4. Pull the remote branch to the local (at this time, both the remote branch and the local branch are available, and an association is established)

  1. Find the remote warehouse and copy the warehouse address

picture

picture

2. Clone the remote warehouse to the local through the warehouse address

  • Find a directory to store your local warehouse

  • Enter the command line in the directory, enter cmd in the address bar and press Enter to enter the command line in the current directory.

picture

picture

3. Enter the command in the command line and press Enter, the remote warehouse will be copied to your local.

picture

5. Submit your project to the remote warehouse

Copy your project to the local repository just now, and then submit it to the remote repository.

1. Set the email
Git config --global user.email "The email address filled in by your registration code cloud"
2. Set the user name
Git config --global user.name "The name of your registration code cloud"
3. Add all files to the cache area (. means all files, you can also specify a file or folder, just write the name directly)

Git add.
4. Submit the files in the cache area to the local warehouse
Git commit -am "description information of this submitted file"
5. Submit the local master branch to the remote warehouse master branch (because the local and remote corresponding branches are called master)
you need to add the -u parameter for your first submission, and you can use Git push directly in the future.
Git push -u origin master

6. Other commonly used Git commands

✡✡✡✡✡

1. View the local branch
Git branch

2. View the remote branch
Git branch -r

3. Check the relationship between the local branch and the remote branch
Git branch -vv

4. View the commit log
Git log
and press q to exit

5. Create a branch
Git branch your_branch_name

✡✡✡✡✡

6.Switch branchGit
checkout your_branch_name

7. Create a branch and switch to the new branch
Git checkout -b your_branch_name

8. Create a new branch based on a certain branch
Git branch branch1 branch2

9. Pull the branch code to local
Git pull

10. Delete the local branch
Git branch -d bugfix01

✡✡✡✡✡

11. Delete the remote branch
Git push origin --delete bugfix01

12. Force commit to remote branch
Git push -f origin you_branch_name

13. Branch merge (merge the bugfix01 branch to the master branch)
① Switch to the master branch
Git checkout master
② Merge branch
Git merge bugfix01
③ Submit
Git push


14. Branch rollback

回滚机制说明:1、在Git中,用HEAD表示当前版本2、上一个版本就是HEAD^3、上上一个版本就是HEAD^^4、通过数字表示之前100个版本HEAD~1005、git log可以查看提交历史,查看commit_id,按q退出6、回滚命令git reset --hard commit_id

15. Force coverage of local warehouse

  • Download the latest version from the remote repository
    Git fetch --all

  • Set the local to the latest content just obtained
    Git reset --hard origin/master

16.Conflict resolution

<<<<<<< HEAD...自己提交的代码...=======...下来的代码...>>>>>>>master

说明:head到=======是自己提交的commit内容======到>>>>>>master是下拉的pull内容删除=======和>>>>>>和重复的代码即可,再推到远程仓库。

Guess you like

Origin blog.csdn.net/m0_58552717/article/details/132744179