Git learning notes (i)

Source: Internet
Author: User

Git: Version control system;

It is said to be the highest-end version control system on Earth;

So I did not know the reason for the situation I went to learn about SVN and missed git for so long, but also used git friends despise for so long;

So I know I can't wait until I have time to learn git again, it's time to take a time to learn git!

The benefit of the version control system is that it can automatically record each version of the change record, for personal development and team development, especially team development has brought great convenience!

Whether it's svn or git, be sure to know at least one version control system after programming!

That's the thing, and now it's time to learn.

Study before said a lot of nonsense, but some is necessary, but now to say is more necessary: Thank you very much in the Internet to disseminate the strangers of learning resources, very grateful to organize and publish learning resources never met Liaoche teacher, thank you for your good intentions, Let my study enthusiasm not due to environmental limitations and empty waste.

Well, it's 17:46, and I'm starting from 13:10 to see Liaoche's git tutorial, and I'll be off work soon. I might need to switch to a combat site, and here's a summary of the results this afternoon:

Install git First:

Windows above directly download the resources to install it;

After the installation is complete, find Git Bash in the Start menu and pop out a command-line window that shows that the GIT installation was successful!

Then enter in the window:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

Installation is complete.

My Linux has been installed, because I entered Git--version and then prompted my 1.7.1 version, so save this step;

But even if there is no installation, I think there is no difficulty, directly download the source package,./configure, make, sudo made install.

Then create a local git library, make a new file, and Git init.

There's more than one hidden property file in this library. Git.

Then you can do some normal file operation in this library;

Just after the operation, execute the command:

git Add.

git commit-m "Info"

This will allow you to submit the.

Use git status to view the current repository's operational status.

The modified content can be viewed using the git diff command.

Git log View history,

git reset--hard head^ fallback operation;

You can replace the head^ with the commit ID;

You can also use Git reflog to view operational records including fallback;

Free switching of versions via the above command.

Then the concept of workspace and staging area, git repository files in the work area, through add to staging area, the final commit is really saved up.

You can add it multiple times and commit all at once.

By ordering git check-file to undo the changes to the version, back to the latest version after the last commit.

There is add nature to delete, git rm filename is the delete command;

The same is only the deletion is submitted to the staging area, and finally a commit is required;

If the deletion is wrong, you can also find it back via git checkout-filename.

Play the remote directly, first you need to go to GitHub to register an account. Registered mailbox activation, and then you can use it.

And do this in the shell. ssh-keygen -t rsa -C "[email protected]"

Get SSH key;

Add this key to GitHub.

After creating a project on the remote, the local shell passes the command:

git remote add origin git@github.com:michaelliao/learngit.git

Connect the remote project, and then execute the command:

Git push-m Origin Master

Push local content to the remote repository;

Likewise by command:

git clone git@github.com:michaelliao/gitskills.git

You can clone or download the contents of the remote repository locally.

Today's release is Git's branch management:

command to create branch switch branches: GIT branch branch name; git checkout branch name;

or directly create and switch past: git checkout-b branch name;

Merge branch with git merge branch name;

Of course, the above is a quick merge, when there is a conflict is not fast merging, need to command:

Git merge--no-ff-m "info" branch name

You can see where the conflict is by using Git diff;

View the structure of the merged branch with git log--graph;

The last command to delete a branch is:

git branch-d branch Name

Incidentally, there is a bug branch also looked at today;

This command git stash is also very useful;

You can use this command when you develop a part that suddenly needs to switch to another branch operation but the current version is not suitable for commit;

You can switch to a different branch after you use Git stash;

You can use the Git stash list to view the bug branch when the other branch finishes switching back.

Continue working on this branch by using the Git Stash pop restore operation.

Well, also work overtime for more than 20 minutes, this afternoon to see so much, I see there is not much left of things, because the night is sure to do the development of things, so the rest of the things to be finished tomorrow.

Liaoche Teacher's Tutorial: Point me Jump!

Git learning notes (i)

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.