Directory
- Tools
- Installation items
- Save the Local Password
- Common git operations
- How to manage our versions and branches
Tools
Git, an open-source version controller, is very popular. Next I will summarize what needs to be developed using git.
Client:
1. msysgit is a functional software on the window platform.
Https://code.google.com/p/msysgit/downloads/list? Q = Full + installer + official + git
2. tortoisegit is a git client management tool.
Https://code.google.com/p/tortoisegit/wiki/Download? TM = 2
3. Git extensions is a git version controller plug-in that provides a graphical user interface for user operations.
Https://code.google.com/p/gitextensions/
4. Git source control provider is a git plug-in for vs 2010 and later versions.
Http://visualstudiogallery.msdn.microsoft.com/63a7e40d-4d71-4fbb-a23b-d262124b8f4c
Server:
If you want to use your server as a version control server. There are twoArticleFor your reference
English http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds
Chinese http://www.cnblogs.com/dudu/archive/2011/06/24/git_on_windows.html
Git documents and books
Git community book: http://gitbook.liuhui998.com/index.html
Git command documentation: http://www-cs-students.stanford.edu /~ Blynn/gitmagic/Intl/zh_cn/index.html
Installation items
When installing msysgit, because the line breaks on Windows (CRLF) and Linux (* nix) platforms are different, submitting the code to the server will change us.CodeLine break in. Select checkout as-is and commit as-is during installation.
Save the Local Password
The local password of the GIT client is saved.
You must be prompted to enter the account and password each time you get or submit the information to the server. In order to reduce the burden, save the account and password locally.
1. Add a home environment variable in windows with the value % USERPROFILE %, for example:
2. Open % home % in "start" run "and create a file named" _ netrc.
3. Open the _ netrc file in notepad, enter the GIT server name, user name, and password, and save the file. Example:
The URL submitted by machine to the server (no port number is required)
Login Username
Password
Common git operations
I. Command operation:
1. View local branches in git Branch
2. view the remote branch in git branch-R
3. Check which files have been submitted (COMMIT), which files have not been submitted, and which files have been modified by git status.
4. Git commit-A submits the modified file, which will jump out of the vim editor and is not recommended. Git commit-a-m submit all.
5. After the gitk is submitted, you can use this command to view all the information after the local file is submitted.
6. Switch git checkout XXX to a branch (XXX)
7. delete a local branch from git branch-d xxx (Force Delete if lowercase D is changed to uppercase D)
8. Git merge XXX merge Branch
9. Git reset -- hard head: After the branch is merged, you want to discard the merged operation. This operation returns to the status before merging.
10. view the logs of the current branch in git log (add -- stat to which files are modified and which files are added or deleted. -- Pretty format the log, for example -- pretty = short)
11. Git diff compares the difference between the current local working directory and the local directory submitted last time. Git diff XXX is different from a branch. Git diff -- cached is the difference between the current index and the last commit. Git diff XXX --./lib differs from files in the lib directory under a branch. Git diff -- stat to check which files of the current Branch have changed. (Press Q to exit and view the difference .)
12. Git pull obtains the latest data from this branch on the server (two operations are performed here, one is get, and the other is merge). Git pull XXX obtains data from a branch. The general practice is to first check the GIT fetch XXX and check the local comparison with the obtained data. The GIT log-p xxx check is completed, and then in git merge xxx
13. When we perform some operations on this branch of git stash, we need to modify the bug of the last submitted version instead of submitting the current modification. We can cache it with GIT stash, and it will automatically return to the version of the previous commit.
14. Git push: Submit the version that has been committed locally to the server. If the version on the server is different from that on the local version (which has already been committed), the pull push prompt is displayed. When a file on the server has been modified, and I have changed the file, the merge conflict operation will be prompted. Git uses
++ <
++ ====
>>>> ++
To distinguish the conflicting locations in the file. You can also add the "+" command before the branch to force push: git push + XXX (Branch)
15. Git tag XXX provides a tag for the version to be submitted. XXX is the tag name.
16. The GIT rebase remote branch cancels the current Branch's commit operation and adds it to the remote branch. For example:
Before rebase:
After rebase:
Without rebase, we directly use pull (the merge operation is performed by default), as shown in the following figure:
There is a possibility of conflict in rebase. If a conflict exists, rebase stops. After resolving the conflict, continue rebase. Git rebase -- continue
If you want to modify some submitted operations during the rebase process. Add "I" Git rebase-I XXX (Remote Branch) to the command ).
2. tortoisegit tool skills
1. There is a connection string in the app. config file. If each person connects to a different database, the connection string will be submitted to the server. Otherwise, a conflict will occur. To solve this problem. It can be assumed that the local app. config has not been changed. For example, the GIT extension plug-in must be installed in the form operation.
Reset the file if you want to keep it consistent with the version on the server.
The assume unchanged command is GIT Update-index -- assume-unchanged <files>
Unnaming is GIT Update-index -- no-assume-unchanged <files>
How to manage our versions and branches
This figure shows how to manage version branches.
For more details, see here