git commit code

Submit the project to the remote branch of github, and now organize the steps:
1. In the project file directory, open Git Bash Here;
 
 
2. Use the git add command to add the file information we want to submit (including modified and new files) to the index library. Enter the following command:
git add .
 
3. Use the git commit command to submit files according to the contents of the index library. Enter the following command:
git commit -m "commit the user's jade"
PS: -m <submitted description information>
-m option is used to submit description information
 
4. Create a new local branch: git branch <branchname>, enter the command:
git branch xf
 
5. View all local and remote branches of the project: git branch -a, and add a "*" mark before the current branch
Extension: git branch View local branch
git branch -r View remote branches
Here, we view all branches, including remote and local, so enter the command: (this step can be omitted)
git branch -a
 
 
6. Switch the local branch: git checkout <branch name>, enter the following command:
git checkout xf
 
 
7. Pull the code of the remote branch to the local branch: git pull <remote host name> <remote branch name>:<local branch name>
For example: retrieve the xf branch of the origin host, merge it with the local xf branch, and enter the command:
git pull origin xf:xf
The remote host name can be queried by git branch -a or git branch -r above, see the figure below:
PS: It is best to update the local code with pull before pushing the code.
 
8. The last step: git push <remote host name> <local branch name>:<remote branch name>
PS: Note that the branch push order is written as <source>:<destination>, so git pull is <remote branch>:<local branch>, and git push is <local branch>:<remote branch>.
 
eg: 
git push origin xf:xf
The above command means to push the local xf branch to the origin host's xf branch.
 
If the remote branch name is omitted, it means that the local branch will be pushed to the remote branch with which it has a "tracking relationship" (usually the two have the same name). If the remote branch does not exist, it will be newly created.
eg: 
git push origin test
The above command means to push the local test branch to the test branch of the origin host. If the latter does not exist, it will be created.
 
 
 
PS: There are three ways to submit remote branches. I use the first method below. You can also try the other two when you are free.
1. Add and commit, then checkout, and submit to the current branch;
2. Add but not commit, you can stash, and then stash apply after checkout comes back, and submit to the current branch after commit;
3. Add but do not commit, nor stash, checkout directly, and then commit, the (commit) record is under the switch branch.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326162209&siteId=291194637