git get started command

Source: Internet
Author: User
Tags git commands

Git is a good thing, just windows under the git because there is a graphical interface, may be a little easier to use, but to tell the truth, it is a little more useful, as for Linux, the pure command line, for the veteran, may find it very easy, but for the novice to the Linux platform, may not be so easy, below, is that I use git part of the experience, mainly related to a few common git commands, please note that only a few commonly used, some rarely used commands I did not write, because it seems that I did not use them, please note that all the commands are in the SSH public key has been uploaded in the case, And Git has been installed successfully.

First of all, you have to initialize, here is a command called INIT, the format of git init this, the command is very good to remember, because almost all of the initialization is the use of this command, this command is to initialize the current directory, tell git, this directory is used by git to develop, All files in this directory can be uploaded to a git server.

Then, the next is to write code, write the code is finished, to upload, then use the Push command, the specific format of the GIT push repository name; to [email protected] For example, push the code for GIT push Origin master This means that you are pushed to the master branch, and you can also push to other branches if you have that branch locally.

Then, the code is finished, you want to look at the other code, then you can clone some items, the command for the GIT clone project address, to [email protected] For example, the cloned code is git clone [email protected]:accacc/ Yii4sae.git, and then wait for the transfer to complete, cloning down, please note that sometimes cloning does not come down, then please check whether you have access to the project right, or whether your public key is correct

Next, perhaps the division of labor, then, each person's code may be different, each person responsible for the part is not the same, then create a new branch, then, the new branch, the command for Git branch, such as: Git branch news, Then we have a new local name called News Branch, the new branch must do something, so, we want to switch to that branch: Git checkout branch name, so, then switch to the branch we want to operate, at this time, you have to do something please feel free ...

Well, since it is a division of collaboration, then your new branch must be pushed to the GIT server, so you have to use the push command, the same, git push repository name such as: Git push Origin news, and your little partner to download your branch from the remote, how to do? With clones? This is not a good idea, because cloning is the cloning of all the code of the entire project, and we only need a branch, a bit wasteful, so we have another command: Git pull warehouse name, such as: Git pulls origin news so that the code of news This branch to local, please note , you are under what branch you are under, and you are not going to create a new branch.

OK, the branch of what is all done, the push sent, the previous push back missing two commands, one is the package command git add file name, generally speaking, will use "." Instead of the file name, which means to package all of the changed files, and then git commit command, can be understood as a comment on the entire change, so that the small partners understand what you did, the specific command is: Git commit-m "comment content", then you can submit a

Sometimes we get the wrong commit, what do we do? Reset bar, first use git log to see the commit record, and then find the version you submitted to the previous version, write down that long string of characters a, and then git reset 334sdfgsd655sd644g; OK, back, your changes are all gone ... Of course, sometimes we just want to give up a change to a file, so ... git checkout file name, guaranteed to return to the state you just came back from the server ...

Of course, maybe we don't know where we've changed, so look at the git status: Git status will see what files you've changed.

At last... Development finished, to the official version of the code, then merge branches Bai ... Git merge merged branch name, note that this merge is to merge the branch name into your current branch, not messy, and then submit it after the merge: Git push Origin master

git get started command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.