Upload
ilya-vorobiev
View
109
Download
3
Tags:
Embed Size (px)
Citation preview
Before start
Pro GIT by Scott Chacon & Ben Straub
https://git-scm.com/book/en/v2
File statusFile in the project
Tracked Untrackedwas in your last commit was not in your last commit
git status
Rebase
• Going to the common ancestor of the two branches • Getting the diff introduced by each commit of the branch
you’re on • Saving those diffs to temporary files • Resetting the current branch to the same commit as the
branch you are rebasing onto • Applying each change in turn.
Rebase
Be careful with it!!!Do not rebase commits that exist outside your repository.
If you are thinking what is better — choose merge
I’ve forgotten to add some files to commit or mess up with message
git commit --amend
• If you had made no changes it would change commit message
• If you had added untracked file to stage it will add it to your commit
I’ve staged wrong filegit reset HEAD filename
Unstages file with name filename
While git reset can be a dangerous command if you call it with --hard, in this instance the file in your working directory is not touched. Calling git reset without an option is not dangerous - it only touches your staging area.
I need to move commit from one branch to another
applying commit C to current branch
git cherry-pick C
I want to switch branch, but don’t want to commit
Store you changes, but without committing.
git stash; git stash apply
Operation with files• git status -s — short status • git diff — actual changes • git diff —staged — staged changes • git commit -m “message” — commit with a message • git commit -am “message” — stages all the tracked files • git branch -vv — shows all branches (including remotes) • git rm filename — untrack file • git mv file_from file_to — renames (moves) file_from to
file_to
History• git log — shows commits history • git log -p — shows the difference introduced in each
commit • git log —pretty=oneline — print all in one line • git log —since=2.weeks — print only commits for 2
weeks • git log --oneline --decorate --graph —all - draw a
graph of branches • etc…