Download git OSX
Download git for Windows
Download git for Linux
Create a new warehouse
Create a new folder, open it, and then execute
Create a git repository.
Run the following command to create a clone version of a local repository:
If it is a repository on a remote server, your command will look like this:
Git clone username @ host:/path/to/Repository
Your local repository is composed of three "Trees" maintained by git. The first is your working directory, which holds the actual file; the second is the temporary storage area (INDEX), which is like a cache area, saving your changes temporarily; the last is head, it points to the result of your last submission.
Add and submit
You can make changes (add them to the temporary storage area) by using the following command:
Git add <FILENAME>
Git add *
This is the first step in git's basic workflow. Use the following command to submit the changes:
Git commit-M "code submission information"
Now, your changes have been submittedHeadBut it hasn't arrived at your remote repository yet.
Your changes are now in the local repositoryHead. Run the following command to submit the changes to the remote Repository:
Git push origin master
You can setMasterSwitch to any branch you want to push.
If you have not cloned an existing repository and want to connect your repository to a remote server, run the following command to add the Repository:
Git remote add origin <Server>
In this way, you can push your changes to the added server.
Branches are used to isolate feature development. When you create a repository,MasterIs the "default" branch. Develop on other branches, and then merge them into the main branch.
Create a branch named "feature_x" and switch it over:
Git checkout-B feature_x
Switch back to main branch:
Git checkout master
Delete the new branch:
Git branch-D feature_x
Unless you push the branch to the remote warehouse, the Branch isNot what others see:
Git push origin <branch>
Update and merge
To update your local repository to the latest changes, execute:
In your working directoryGet (FETCH)AndMerge (merge)Remote modification.
To merge other branches to your current Branch (for example, Master), execute:
Git merge <branch>
In both cases, git tries to automatically merge the changes. Unfortunately, this may not succeed every time and may happenConflicts). In this case, you need to modify these files to manually merge these files.Conflicts). After modification, You need to execute the following command to mark them as merged successfully:
Git add <FILENAME>
Before merging changes, you can use the following command to preview the differences:
Git diff <source_branch> <target_branch>
It is recommended to create tags for software releases. This concept already exists and also exists in SVN. You can run the following command to create1.0.0Tags:
Git tag 1.0.0 1b2e1d63ff
1b2e1d63ffIt is the first 10 characters of the submission ID you want to mark. You can use the following command to obtain the submission ID:
You can also use the first few digits of a submitted ID, as long as the ID point is unique.
Replace local changes
If you make a mistake (of course, this should never happen), you can use the following command to replace the local change:
Git checkout -- <FILENAME>
This command replaces the files in your working directory with the latest content in the head. Changes that have been added to the temporary storage area and new files will not be affected.
If you want to discard all your local changes and submissions, you can get the latest version history on the server and direct your local branches to it:
Git fetch Origin
Git reset -- hard origin/Master
Built-in graphical git:
Color git output:
Git config color. UI true
When the history is displayed, only one row is displayed for each submitted information:
Git config format. Pretty oneline
Add files to the temporary storage area in interactive mode:
Link and resource graphical Client
- Gitx (L) (OSX, open source software)
- Tower (OSX)
- Source tree (OSX, free)
- GitHub for MAC (OSX, free)
- Gitbox (OSX, App Store)
Guide and manual
- Git community reference books
- Professional git
- Think like git
- GitHub help
- Git illustration