[commit]
# shows the contents of a file when a commit, git show [Commit]:[filename]
# shows the most recent commit of the current branch $ git reflog
Eight, remote synchronization
# Download all changes to the remote repository $ git fetch [remote]
# Show all remote warehouses $
There are 2 commands in git that get the latest version from the remote branch to the Local:1. Git fetch: the equivalent of getting the latest version from remote to local, not automatically merge
Git fetch origin master
git log-
Git command for obtaining and creating projects, git command for obtaining Projects
Obtain and create project commands
Git init
Use git init to create a Git repository in the directory. You can do this at any time and in any directory, and it is completely localized.
Execute
server, or someone else's personal computer (but generally no one uses it), and each remote repository has a short name and an address, repository. The remote repository alias at the beginning of the clone code is often default to origin, and the remote repository you add can optionally specify an alias, and all remote repositories can modify the alias at will. You can get the code (git fetch command or
[Git] Error prompt caused by Git not initialized, git error prompt
Business scenario: Use gitto submit the readme.txt file. The following message is displayed:
[pms@yhd-jqhadoop39 /home/pms/workspace/ouyangyewei/learngit]$git commit -m 'add readme.txt'*** Please tell me who you are.Run
Tag: git1. Background
Today I learned how to tag a project, modify the tag version number for this project, and then directly push the version number to the server, which is much easier and easier to manage the project.
2. Tag 1. query existing tags. You can use the GIT tag command to query a specific version. You can use git tag-l 'v *'
git tag2. Create a tag fo
it is a commit generated by merge, it indicates another parent branch except the HEAD.FETCH_HEAD: the object and ref information obtained using git-fetch are stored here, which is prepared for future git-merge.ORIG_HEAD: Save the SHA-1 value of the parent nodeHEAD ^: indicates the parent information of the HEAD.HEAD ^: indicates the parent information of the HEA
risk of losing all historical update records.distributed version control systemDistributed version management system is to solve this single point, in such systems, such as Git, Mercurial, Bazaar and Darcs, and so on, the client does not just extract the latest file snapshot, but the original code warehouse completely mirrored down. As a result, any server that works together fails and can be recovered using any of the mirrored local repositories aft
' Git remote Add ' command to add a remote server side,
Example: Git remote add Origin git://github.com/someone/another_project.git
The above command will add the URL address ' git://github.com/someone/another_project.git ', the name is origin of the remote server, in the future to commit the code only need to use the
area and workspaceCodeDifference$ git diff# shows the difference between staging area and the previous commit $ git diff--cached [file] # shows the difference between the workspace and the current branch of the latest commit $ git diff HEAD # show two commits difference $ git diff [firs T-branch] ... [Second-branch] #
fetch will need to merge a bit, and pull a command contains fetch and merge two operations.And then say the similarities and differences between the merge and rebase, they are used to merge the code, different when the rebase operation is slightly more complex, but more careful, it will be remote files and local files to compare, and mark out the conflict, when the resolution of all conflicts after the add
Operations
1. Create a version Library
Git init reponame # create a local database
Git clone git@github.com: jatsz/snippets. Git # create a repository in remote clone mode
2. Add files to the stage)
Git add file # Add the file to the version library
modified.
$ Git blame [file]
# Display the differences between the temporary storage zone and the Workspace
$ Git diff
# Display the differences between the temporary storage zone and the previous commit
$ Git diff-cached [file]
# Display the differences between the workspace and the latest commit of the current Branch
$ Git
Wst@192.168.88.46:/home/wst/wanghanbo/wireshark.git
In this way, each participating team member also has the first code that is consistent with the code base version.
3. The operation in development
Now, we're going to start developing. can refer to
http://blog.enjoyrails.com/2008/12/31/git%E4%B8%80%E5%88%86%E9%92%9F%E6%95%99%E7%A8%8B/
first let's look at how to update the local code to the latest version:
The first method uses
. Create a new local project#mkdir Github-test#cd github-test/#git Init#touch README#git Add README#git commit-m ' My first commit 'To define a remote server alias origin#git remote Add origin [email protected]:xxx/github-test.gitLocal and remote merge, local default is master#git
changes to the remote repository
$ git fetch [remote]
# Show All remote warehouses
$ git remote-v
# Display information for a remote warehouse
$ git remote show [remote]
# Add a new remote repository and name
$ git remote add [shortname] [url]
, the push process may require you to verify your identity. If nothing goes wrong, now look at your remote branch using your browser, and Hello.txt is already waiting for you.3. Clone Repository –git CloneOpen source projects on GitHub where people can see your code. You can use git clone to download to local.$ git clone https://github.com/tutorialzine/awesome-pr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.