Home > Article > Development Tools > git pulls code to local
The method for git to pull the code to the local is: first open the git command window and enter the command [git clone github warehouse address]; then press Enter to pull the code to the local warehouse.
Step 1: Pull the remote code
git clone https://github.com/…/PrettyGirls.git
Step 2: View local branches and remote branches
1. cd PrettyGirls to the project directory;
2 , git branch -al to view all local and remote branches.
All branches are successfully seen here: master is the local branch, and the asterisk * in front indicates the branch being used
with remotes in front Branches are all remote branches.
The third step is to associate the remote branch with the local branch
1. git pull origin master
(If you want to pull to the local dev branch, first git checkout -b dev, and then use git pull origin dev, thus binding the local dev branch to the remote origin/dev)
This command is to Associate the local branch with the remote branch, and pull the remote branch origin to the local branch master
If there is a sub-branch 1.0.0.1 under the remote branch origin, use git pull origin/1.0.0.1 master. This will transfer the local branch The master branch is bound to the remote origin/1.0.0.1
2. git branch -vv
You can see the blue part origin/master behind the master, indicating that the master branch has been linked to origin /master is bound together.
3. For the code that has been associated, you can synchronize it by directly entering git pull
The fourth step is to upload the local code to the remote branch
1 , git add. (You can fill in the complete path, the dot means all the files in the directory)
Add the local file acb.txt you have modified. Here is the relative path
2. git commit
Use git commit It is to upload this txt file to the local branch
3. git push
The result of this command is to upload the committed data abc.txt in the local branch master to the remotely bound master branch
The above is the detailed content of git pulls code to local. For more information, please follow other related articles on the PHP Chinese website!