Git's add, commit, push command

Simple code submission process

  1. git status to see the difference with respect to the work area code is the temporary area
  2. git add. all the code changes the current directory to add from the work area to the staging area . represents the current directory
  3. git commit -m "xxx" to add the buffer contents to a local warehouse, xxx is a description of the changes made
  4. git pull --rebase pull tag and a remote repository combined (if there is a conflict that requires manual process) may also be used as git pullpull
    • git pull = git fetch + git merge
    • git pull --rebase = git fetch + git rebase
  5. git push origin master (if there is a conflict is not resolved not submitted) will push the local repository to the remote server, origin is a remote host, master representation is a master branch on the remote server, branch name can be modified

Git add

git add [parameters] <path>  
role is to submit the code we need to add from the work area to the staging area, git is to tell the system which we have to submit a file, then you can use the git commit command submitted.
The following are used for convenience. Identifies the path. Represents the current directory, the path can be modified, have the following scope within the repository.

git add .
No arguments default to add and modify operations untracked files newly added file system to git staging area, not including the deletion of note

git add -u .
After -u said it would add the trace file has been modified, and deleted files to the staging area, not including the newly added file, note that these deleted files are added to the staging area and then be submitted to the repository and pushed to the server this file will disappear from the git system.

git add -A .
-A represents all tracked files and modify and delete new untracked files are added to the staging area.

Git commit

git commit mainly to the staging area where the changes to be submitted to the local repository. Every time we use the git commit command will generate a 40-bit hash value in the local repository. The hash value is also called commit-id, commit-id when the rollback version is very useful, it is equivalent to a snapshot be back here at any time in the future by a combination of the git reset command.

git commit -m "xxx"
-m parameter indicates that you enter behind the "message" directly, if not -m parameter, then enter xxx is not directly, but will call a general vim editor to let you enter the xxx, xxx that is, we use to submit a brief description of this statement.

git commit -am "xxx"
-am equivalent to -m -a
-a parameters can be tracked all the files in the execution modify or delete operations are submitted to the local repository, even if they have not been git add to add to the staging area, attention: newly added file (ie not git file system management) can not be submitted to a local warehouse.

Git push

In using the git commitcommand will modify the submission from scratch to a local repository, only the last step will be the repository of the local branch pushed to the corresponding branch of the remote server. git push general form of git push <远程主机名> <本地分支名> <远程分支名>, for example git push origin master:refs/for/master, i.e. is pushed to the master branch corresponding to the master branch on the remote host origin, origin is the name of the remote host. The first master is the local branch name, the second master is the remote branch name.

git push origin master
If the remote branch is omitted, as it indicates that the local branch push remote branch (generally both the same name) thereto trace relationship exists, if the remote branch does not exist, it will be newly created

git push origin :refs/for/master
If you omit the local branch name, then delete the specified remote branch, because this is equivalent to pushing an empty local branches to remote branches, equivalent to git push origin -delete master

git push origin
If the current branch and a remote branch trace relationship exists, then the local branch and a remote branch can be omitted, the push current branch corresponds to the branch origin host

git push
If the current branch is only a remote branch, then the host name can be omitted, shaped like a git push, can be used git branch -rto view the remote branch name

About refs / for:
refs / for significance is that after we submit the code to the server is required to perform code review after the merge, and refs / heads do not need

Reference from: https://blog.csdn.net/qq_37577660/article/details/78565899

Guess you like

Origin www.cnblogs.com/tangjian07/p/11282773.html
Recommended