Git some small experience and tips overview

  

to install git-doc, also recommended git graphics client gitg, much better than gitk, with apt-get install
HEAD is the current working version of the pointer &ndash ;global save is the current user configuration, the configuration file is saved in ~/.gitconfig– system is all users in the system, the configuration file is generally in /etc/gitconfig, nothing is added to the project directory configuration file in the current directory, in the project Git config –list in the .git folder can view all configuration information, there are different names because there are different configuration files, the actual basic configuration will be git config –global user.name yisengit config –global user.name [email protected] config –global core.editor vim

coloring git
git config –global color.ui true This will look good
autocomplete script< Br> git default to enter the full command, and can not be like svn st, ci, co, a little inconvenient, in the git source code folder, the git-completion.bash script in the contrib/completion directory can be Auto-complete copy it to ~/.git-completion.bash, then source it, and add the command to the startup script echo“source ~/.git-completion.bash >> ~/.bashrc”Now we You can use the Git command alias
Git command alias
$ git config –global alias.co checkout$ git config –global alias.br branch$ Git config –global alias.logg “log –pretty=format:’%h – %an -%ad -%s’& rdquo; git log -p View the difference between each version git log a..b View the log git reflog between version a and b. You can view each change git reset HEAD~1 Undo the last change and restore the data. Use reflog to check the SHA value of the submitted commit, and then directly git branch recover-branch ab1afef( The first few SHA values) git checkout -b newbranch = git branch newbranch + git checkout newbranchgit checkout -b newbranch develop = git checkout develop + git checkout -b newbranch Never rebase those updates that have been pushed to the public repository .
If you follow this golden rule, you will not make a mistake. Otherwise, the people will hate you, and your friends and family will laugh at you and spit on you. If you think of rebase as a means of cleaning up commit history before pushing, and only rebase commits that will never be exposed, then there won't be any problems. If you rebase those commits that have already been exposed, and at the same time others have used these commits for subsequent development work, then you have trouble. Ignore adding some files
used to git add. to add all changes, if you do not want to be added to the repository by default, you can create a new .gitignore file in the project directory, enter the file name, blank line separation , you can use the * sign. Shared warehouse in LAN
No SSH: This machine uses git clone – bare xxx xxx.git to clone a pure repository xxx.git and put it on the server in a shared directory that all project groups can access. For example, NFS, assuming /mnt/git/xxx.git to mount to your own /mnt/git, then git clone /mnt/git/xxx.git to add the remote host: git remote add origin file://192.168.xx/Opt/xxx.git gets the update: git fetch origin This gets a pointer to the origin/master branch, can't be modified, can be merged into its own trunk git co master, git merge origin/master, or create a new branch to work, git checkout -b new_br origin/master The commands to get updates and merge to the current branch can be merged into: git pull origin master (master:master)

Copyright © Windows knowledge All Rights Reserved