Git

Jihyo Jeon·2022년 12월 26일
0

soju-study

목록 보기
1/4
post-custom-banner

About

Branching and merging

Git allows and encourages you to have multiple local branches, entirely independent of each other. You can do:

  • Frictionless Context Switching
  • Role-Based codelines
  • Feature Based Workflow
  • Disposable experimentation
  • etc.

Small and fast

Git is smaller and faster than SVN(another version control tool).

Distributed

Git Clone

  • Multiple Entire Backups
  • Any Workflow is possible
    - Subversion-style
    - integration manager
    - dictator and lieutenants

Data assurance

Ensure the cruptographic integrity of every bit of your code! with commit id, you can be sure that nothing in its history was changed.

Staging area

Staging before commit
1. add to staging area
2. commit to repository

Free and open source


Git Alias

Collection of git alias - Jihyo personal!

[alias] in '~/.gitconfig'

graph = log --graph --branches --tags --remotes --oneline --decorate --pretty=format:'%C(auto)%h%C(auto)%d %Creset%s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"

undo = reset HEAD~1 --mixed

git graph

: Alias for showing the graph of branches on console

git gone

: Alias for removing local branches that are gone on remote

  • git fetch --all --prune just fetches remotes info
  • git branch -vv list branches and pipes output lines to awk
  • awk '/: gone]/{print $1}' find lines with gone, select first column (which is branch name) and pipe to xargs
  • xargs git branch -D takes received branches names and deletes them

git undo

: Alias for reseting the previous commit on this branch, and check out all the previous committed changes as uncommitted


Useful git commands

git commit --amend

: Changing the most recent commit BUT need to force push

  • usecases
    - add changes to last commit without editing its message
    $ git add .
    $ git commit --amend --no-edit

    	- edit commit message
    		`$ git commit --amend`
    		or
    		`$ git commit --amend -m "new commit message"`

git rm -r --cached

: Removing files from tracking

  • usecases
    - make gitignore work after some commits...
    $ git rm -r --cached filepath
profile
Software Engineer in London, UK
post-custom-banner

0개의 댓글