git pulls remote branches and associates local branches

git pulls remote branches and associates local branches


Recently, I found that some friends always ask me the same question, how does git pull the code and connect it to the local; it seems to be a simple question, but it will report an error when it is operated. The following summarizes a few points that I hope can help you:


1. Create a blank folder locally;

2. Pull the folder into VScode and open the terminal;

3. Enter git init to initialize the local environment;

4. Copy the git warehouse address and enter git clone xxx (xxx is the git warehouse address you copied);

5. Create and switch to the local branch name git checkout -b xxx (xxx is the local branch name you took yourself);

Six, view all branches git branch -a;

7. Pull the remote branch git pull origin xxx (xxx is the name of the remote branch you want to pull, pay attention to the space);

8. Associate the remote branch with the local branch git branch --set-upstream-to=origin/xxx ccc (xxx is the name of the remote branch, ccc is the name of the local branch you want to associate);

9. View the branch status git branch -vv shows green + blue, which means the association is successful;

10. The follow-up is the basic operation, git add .

Eleven, git commit -m '[branch name] add: xxx'

12. git push can push directly because the association is successful;


Summarize:

不要太依赖于git管理工具,多敲敲命名行,熟记余心;



On the road to the front | I know very little, but I am good at learning.
If you have any questions, please leave a message to discuss.

— Follow me: Don’t get lost on the front end —




Guess you like

Origin blog.csdn.net/weixin_44873831/article/details/130698861