The most basic entry-Git - the local warehouse operations

Add a local Git repository

First of all, we want to create a local repository (that white is a folder )
and then enable our Git Shell (in wndows Start Menu -> All Applications -> GitHub, Inc folder inside)

Open is like this:
Git Shell

Chinese is garbled, ignore it.
I have established here is a Git local repository , so it will exist a master branch (do not understand it does not matter, mentioned later).

Now let's move to the newly created local repository (that is, folder ).
First of all, you first find the folder where your letter and my E drive, so I type E: and press Enter , so that we can enter the E drive.
To enter your own local repository, then, need to re-enter cd webrenji (This is one of my local warehouse) Press Enter .

Note: Suppose your folder built in the D drive github git folder inside the folder, you must first enter the D drive, in cd git Enter into the git folder, and then cd github Enter into the folder github .

like this:
Into the local repository

After you enter the local repository should be no back [master =]
do this step, you have successfully entered your future local warehouse, now, let take over your Git repository.

Operating your local repository

1. By git initinitializing local repository, create a file .git let you take over Git repository.

After initialization is complete in Git Shell inside your local repository behind the name will also appear [Master] .

Let's first in your local repository to build a the Readme.txt , add a line hello world
( do not add content to this use Notepad !!!! Notepad ++ pretty good, Atom what editors have no problem no trouble on their own official website to download. Do not ask Why, after reading all articles, please turn yourself to the blog of Liao Xuefeng , in-depth understanding of Git.)

2. After the addition is complete we entergit add readme.txt

git addCommand is to submit the file to the temporary office, not a formal submission, please be sure to pay attention.

And this time will not be any special circumstances, after changing his party, plus [master] there are things change color. In the unix world, no news is good news . So do not panic, take your time.

3. git commit -m "a"to formally submit the code.
Note: A equivalent of a comment to be filled in by you, each time you submit the code, write about the comments, so that later version rollback know which version of the back, or else you go cry. (Example:git commit -m "1st submit" )

4. git reset --hard HEAD^rollback to the previous version
if required rollback on two versions, then git reset --hard HEAD^^
if you need a fallback version on n, thengit reset --hard HEAD~n

5. Use git logto view the update log, and can git reset --hard 版本号roll back to any version. Note: The version number in git logthe code below to see the inside, there is a commitThese asterisk is the version number, just enter the digits before ( please at least more than 5 digits ) on the line, Git will automatically help you find the version.

6. Use git rm 文件名is used to delete files from the local warehouse, but in fact you directly to my computer enter delete files just fine.
But if you do not accidentally delete the wrong hands residues, do not be afraid, we can git checkout 文件名restore the latest version, or use git checkout .all of the files to recover deleted, it is not it cool?

summary

The first time git initafter the next time and then actually have not initialized again, because Git .git file has been generated, .git files are used to store your version information, so please do not delete the .git files. It may be asked, why I did not .git repository file, it is because auto-hide, do not ignore it.

Remember, be sure to follow the order to submit job files, first git add 文件名or git add .(this is where you submit all files to the temporary directory at), and finally, that is git commit -m "巴拉巴拉", this step is temporarily stored inside the file at the formal submission, after then, we will be able to carry out the next step to upload the distal end of the code base.


Git inside there are some other commands, I did not list them here, if you're interested, you can look at Git commonly used commands

Guess you like

Origin www.cnblogs.com/homehtml/p/12573964.html