Use Git to push code on GitHub
We use Git as a version control, and of course we use it with GitHub, a local library, a remote library, and two combinations that can be used for a lot of convenience. But the push code on GitHub might not know the steps, or just a little bit of time, here's the step I'll give you:
git remote add [name] [address of the repository]
This step is to add a remote library locally (this library to be built on GitHub beforehand), such as I give the remote library name Jcman, the address is: [email protected]:jcman/test.git, so the complete command is: Git remote add Jcman [email Protected]:jcman/test.git This adds a remote library, Jcman later represents the remote library on GitHub, and we push the code on the Jcman to GitHub.
Git add-a
This is a transient zone that adds modified content to Git
Git commit-m "Some things that have changed the interface this time"
This is about adding the contents of our add to the current branch, adding a little note explaining what was changed
git push Jcman Master
This is the key to the push code on GitHub, and the push code on the Jcman is push to the remote library on GitHub, but we push the current master branch, and if it is the other branch, it will be the name of the other branch.
Modify the comment content of a commit
We sometimes write comments that may need to be modified when we commit, because for some reason, Git also gives us a way to modify them:
Git commit–amend
This allows us to enter the interface of the Vim edit box, as follows:
Now that the edit box is not in the edit state, we press the I key first, so that the Vim editor is in the editing state, after modifying the comments, we want to exit the Vim editor, we press the ESC key, and then press: WQ, so we modify the content.
This modifies only the last commit record, and if you modify the previous comment, then we need another method.
Git rebase-i head~3
If you modify which content to change the current line of pick to edit, after exiting, with git log to look at, we will see the current most recent comments will become the comments we need to modify, that is, the role of the line to change our comments to the current latest comment, We modified the comments and then put the comments back to the original place, thinking in time, and then we use Git commit–amend to modify, as before, and then we use the following command to restore the order of comments.
Git rebase–continue
So we can change the order of the comments, using Git log to see that the comments have been modified, "it is important to note that we can not push when we modify the commit, if after the push, we have to modify the commit comment, So next time we can't push it. Will prompt you wrong, the specific solution I have not found, so we must be in the push to ensure that we will not modify the contents of the commit, otherwise it will not be easy to push.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Common git commands