Get Started. It's Free
or sign up with your email address
Rocket clouds
Git by Mind Map: Git

1. Cancel commit

1.1. on local, before push

1.2. after push to master (latest)

1.3. after push to master but master was already updated by other commits

1.3.1. git revert <SHA>

2. Merge

2.1. How to cancel merge with conflicts

2.1.1. git merge --abort

2.2. How to merge latest changes from remote master to local branch?

2.2.1. // in your local branch git pull origin master

2.3. What was lost during merge?

2.3.1. git log --merges find R = merge result commit find X = first commit find Y = second commit git diff X R git diff Y R (shows what data from X/Y is missing in result commit)

3. Update commit

3.1. Add some changes to the latest commit (before push)

3.1.1. git commit --amend

3.2. Fix latest commit message (before push)

3.2.1. git commit --amend -m "updated message"

4. Work with single file

4.1. Cancel changes in one file, revert to the latest commit state

4.1.1. git checkout -- <bad filename>

4.2. Restore file as it was at the moment in time

4.2.1. git checkout <SHA> -- <filename>

5. Get information

5.1. Who changed the lines 10-15 in the file

5.1.1. git blame -L 10,15 <filename>

5.2. Commit log

5.2.1. git log

5.3. Detailed user actions

5.3.1. git reflog

5.4. Get changes for single file

5.4.1. git log -p <filename>

5.5. Get changes for merge

5.5.1. git diff <2nd SHA>...<1st SHA>

5.6. Get information about merges only

5.6.1. git log --merges

5.7. Get master branch history

5.7.1. git log --first-parent

5.8. What branch does commit refer to?

5.8.1. git reflog show --all | grep <SHA>

6. How to properly push changes from custom branch

6.1. git checkout master git pull git checkout custom-branch git merge master <fix conflicts if necessary and commit them> git checkout master git merge custom-branch npm run lint <check if no errors while compiling> git pull git push

7. Cancel changes

7.1. Cancel changes from last commit (with copy to clipboard)

7.1.1. git stash

8. Tracking files

8.1. How to stop tracking file

8.1.1. git rm --cached <filename>

8.1.2. git rm --cached <filename> -r