Git tutorials:
http://www.liaoxuefeng.com Click on git tutorial
We can first go to this website to learn, my side is the notes, mainly I see the tutorial did not solve the problem!
1, commonly used directives:
Git init: command to turn this directory into a repository that git can manage
git add: Tell git to add a file to the repository, followed by a filename or *
git commit: Tell git to submit the file to the repository, followed by-M "Modified description/Commit description"
Git Status: Command allows us to keep track of the current state of the warehouse
git log--pretty=oneline: command to see the history of the changes:
Cat Readme.txt: View current file contents
git rm test.txt: Deleting a file
—————————————————————————————————————————————
How to add or remove it on this basis?
follow the above basic approach:
git Add file name
git commit-m ""
git push
—————————————————————————————————————————————
If you are uploading files in bulk:
git Add */.
git commit-m ""
git push (* or.)
—————————————————————————————————————————————
If you are deleting GitHub files in bulk:
git add-a
git commit-m "delete"
git pull-u
git push (* or.)
—————————————————————————————————————————————
- u simultaneously updates the local
—————————————————————————————————————————————
2, how do I link with GitHub? ( including multi-person collaboration )
1th step: Create SSH key:ssh-keygen-t rsa-c "[email protected] (email)"
After entering these, you will always enter the line, and then go to see your C-Disk user folder is not more than a. SSH folder,
There are two files of Id_rsa and id_rsa.pub.
2nd step: Login to GitHub, click "Setting", you can see "SSH Keys" and then click on the page:
3rd Step: Click "Add SSH Key", fill in any title, paste the contents of the Id_rsa.pub file in the Key text box
3, multi-person collaboration:
1,github allows you to add a key: As long as the participants in this project will follow the first step in the second step to operate, so that you can download and upload items.
2, is to clone a local library with the command git clone: git clone [email protected]: your own on github username/filename. git,
Note that the site uses HTTPS by default, so you just click on SSH to show it as I do, so the input will download the items you want on GitHub.
(in addition to the slow use of HTTPS, but also the biggest trouble is that each push must enter a password, but in some only open the HTTP port of the company can not use the SSH protocol and can only use Https,git to support a variety of protocols, including HTTPS, But the native GIT protocol supported by SSH is the fastest. )
4, Branch Management:
Branching this piece, I was just beginning to feel strange, because in the local is not added a branch folder to you, I understand is to add branches on the site.
git checkout: The command git checkout-b test means to create and switch to the test branch (test is the branch name).
Git branch: command lists all branches with an * number in front of the current branch
Git merge: Commands are used to merge the specified branch into the current branch. After merging, and then looking at the contents of the Readme.txt, you can see that the latest commit with the Dev branch is exactly the same.
Git merge: command to merge the specified branch to the current branch
git branch-d dev: Remove Dev Branch
Here's a quick tutorial to push from local updates to GitHub mutual:
—————————————————————————————————————————————
1,git clone [email protected]: your own on github username/filename. git, download the GitHub project first,
2, create a branch: git checkout-b dev (Dev is the branch name, defined according to your own reality);
3, and then you push your files to GitHub:
1) First enter your working branch dev, then git add * (* or specify file name)
2) git commit-m "yourself on this push to description"
3) If the SSH link fails, perhaps your colleague has updated, git branch--set-upstream dev origin/dev, then git pull local update and then push
4) git push or GIT push Origin dev pushes to the main project page or pushes to the specified branch
5) You or your co-workers develop together, then the question is: your colleague if the direct git pull local update will prompt the failure, because there is no local dev branch and remote origin/dev branch to specify the link,
Depending on the hint, set dev and origin/dev the link, so enter the command:git branch --set-upstream dev origin/dev
(特别注意:origin是可变的,所以你要注意假如origin是失败的话,那么换成你自己原来在git remote -v 所看到的,而且这个要注意不要忘记,不然你推送或更新会出现问题)
6) It is now possible to continue playing the code.
—————————————————————————————————————————————
Other not special to pay attention to, I summed up is the general difficulty (for beginners), the problem can be solved, the rest is on your own.
Git Learning Summary