Use Git to manage projects on your own server

Source: Internet
Author: User
Tags using git

Git is a very powerful distributed version management tool, and unlike SVN, it's easier to add branching and distributed management in a local way. But a lot of students will be confused when using git, so let me introduce git's common commands.

git clone [url]: Clone a repository to a new directory.

Git init: When using this command, start by CD we need to build the project folder. The above two commands are the most commonly used basic commands, the next is to say in the project operation, the need to add, submit, push and other commands.

git add [filename]: Add a file to the index, where git add can be followed by a ".", plus a point meaning to add all new files into the index.

Git commit-m "": Commit the changes in the current workspace,-M to write a line to submit information, which many programmers will feel very troublesome, so do not care about this submission, but I would like to remind you, this information is very important, especially when many people develop together, Detailed information can give other developers a good version of the information, thereby saving the development of communication time. You will also give yourself a message similar to the version notes, so as not to cause forgetting when the version iterations are too large.

git remote add origin [Git_url]: This method should be called if you need to connect a local version to a remote server. The git_url behind is a directory that you copy on the remote server. If you use this command, you cannot use push to the remote branch.

Git push origin [branch name]: commits the local branch (branch name) to the remote branch. This is nothing to say, the local trunk branch is pushed to the server branch.

But if you are a multi-person developer, you need to check the remote branch version is not more than your local version of the update, you can use the Git log this command to view all the information submitted. If the current version is too old, there will be a problem when pushing. This time we need to use git pull this command, to draw the remote version of the content, if the branch does not conflict, you can use git push push local branch. If we are not able to see the file on the remote server at this time, we are very anxious, how to do? Use git reset--hard to completely overwrite the current working version with the files in the code base.

At this point, the basic git operation is complete, and of course, if we develop the project, these commands are far from enough. For team development, the most important thing is the control of the branch, so in git, the Branch command is important.

Git branch: View local branch.

git checkout [branch name]: switch branches.

GIT branch [branch name]: Create a branch.

git merge [branch name]: merges the branch with the name [branch name] with the current branch.

git branch-d [branch name]: Deletes a branch named [branch name].

These commands in Git are particularly important, I hope students have the need to use, if there is any problem, you can leave a message, welcome to add.

  

  

Use Git to manage projects on your own server

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.