Git installed on a Linux server
yum -y install git
git config --global user.name "name"
git config --global user.email "email"
globa parameter indicates all warehouses will use this configuration on this machine, of course, also possible to use the specified configuration of the designated warehouse
Two ways to create a warehouse of:
General warehouse git init bare repository git init --bare
See the difference between the two https://segmentfault.com/q/1010000004683286/a-1020000004684114
When you create a common library, in addition to the .git directory, you can see all the all the source files contained in the library, have a browse, modify the local library (add, commit.delete)
In general, a bare library is often used to create a shared library as we work together, everyone can fill push their own local modifications, a common way in the back of the library name with .git
git status to view the current status of the warehouse
git diff view the contents of the modified
git commit submit
git log submission history
git reflog history command
git reset --hard HEAD ^ file rollback
git reset --hard 23134 (the version number in front of several)
Performing version rollback amount of time to perform the git reset --hard 12312, and now regret it, I want to return to the state of implementation of the latest commit git reflog see the latest submission of execution id get reset --hard lastid to return to date
git chekout - text.txt discarded modify the workspace, which makes the file back to the state at the last commit or add
Delete files
git rm filename then the commit git
git the Push Origin Master
If you manually delete the file you want to recover files rm -rf 1.txt git checkout - 1.txt restored version of the files from the repository
git checkout will be replaced with a version of the workspace in the repository version, whether it is working to modify or delete, can be a key to restore.
About branches.
Check now in which branch git branch create a branch git branch name to switch to a branch git checkout name created and switched to a branch git checkout -b name merge a branch to the current branch git merge name deleted branches git branch -d name to switch to a branch after that is not seen in the b branch changes files created after the merger branch is visible
The work-site repository git stash view a work site git stash list to restore the site of two ways after 1 git stash apply stash recovery does not delete the content, you need to delete drop by git stash 2 git stash to stash while POP restore content is also deleted
View remote database information via git remote git remote -v display more detailed information
Multiplayer branch division of labor cooperation
Use git push origin branch branchname push their own modifications if push fails, because the remote branch is newer than your local branch using git pull merge if associated with conflict, conflict resolution, and submit a local post no conflict or to get rid of the conflict and then git push origin branch branchname push can be successful if git pull prompted "no tracking information" indicating that the local branch and remote branch does not link the relationship between use git branch --set-upstream branchname origin / branchname
git config --list view the configuration of git
Set up a git server
Reference links http://www.cnblogs.com/dee0912/p/5815267.html
git init --bare gittest.git create a bare repository (no bare warehouse Workspace)
Create a file under the post-receive hooks
Content
#!/bin/bash
git --work-tree=/home/www checkout -f
chown git:git post-reveive
chmod a+x post-receive
Address is the git @ ip: /home/dir/git.git
Every client should pull git clone and password
Key speak client authentication on the server
server configuration
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
Restart sshd service
service sshd restart
New .ssh directory in the user directory git
The client public key file is written authorized_keys
chmod 600 authorized_keys
chmod 700 .ssh
Execute git clone git gui in the windows to see if you can clone warehouse
Promote modify the file to the main branch, look at checkout directory without changes in post_receive
If you still like to enter a password, check the key file permissions and so on appear owner