Create
- An empty project creates Git
- cd ~/project/myprojects
- git init
- git add .
- The ones that already exist give I his warehouse clone down
- Git clone git.ids111.com/xxxx/xxxxad…
Show
- Shows what changes are currently being made to files that are not temporarily stored in the local cache
- git status
- Changes to trace files
- git diff
- Contrast branch difference
- git diff
d2
- View the COMMIT records
- git log
- Who changed what in the document and when
- git blame $file
- View the file submitted by $ID
- git show $id
- View all branches
- git branch
Revert
- Fall back to a version of the commit
- Git reset –hard XXXX
- Git reset –hard HEAD^
- Git reset –hard HEAD~3
- Git push -f forces the commit to fall back to the version
- Git revert is used to “reverse” a version in order to undo changes made to that version
- Git revert -n XXX
You can use this method if you want to undo a previous version but want to keep a later version of the target version. You end up with a new version that undoes what you don’t want and keeps the previous version
Branch
- Switch branch
- git checkout $branch
- Merge branch1 into Branch2
- git checkout branch2
- git merge branch1
- git commit -a ‘xxxx’
- git push
- Create a branch based on HEAD
- git branch $branch
- Create branch Branch2 based on Branch1
- git checkout -b branch2 branch1
- Delete a branch
- git branch -d xxx
Update
1.fetch lastest changes from origin
- git fetch
- pull lastest changes from origin
- git pull
Git fetch differs from Git pull.
Git Fetch is to remotely fetch the latest version locally, but does not automatically merge. Git pull takes all remote indexes and merges them into the local branch. Git pull is faster with the same effect. In practice, Git fetch is more secure because we can see the updates before merging and then decide whether to merge
Publish
- Commit Local files
- git commit -a
- Patch it for other developers
- git format-patch origin
3. Push commit to Origin
- git push
- Put a tag or a version number
- Git tag v1.0