미국 공학박사 아빠의 코딩 연구소

Git Terminal Commands
Want To Commands
Clone a repository Clone a repository as my_folder:

$ git clone my_ssh_address(e.g., git@github.com:user/myproject.git) my_folder


Clone a specific branch of a repository as my_folder:

$ git clone -b my_branch my_ssh_address my_folder

Upload changes to a repository Add/stage changes Add a file:

$ git add filename


Add all changes:

$ git add -A


Add new files and modifications, without deletions:

$ git add .


Add modifications and deletions, without new files:

$ git add -u


Commit Added/staged changes Commit the added/staged changes:

$ git commit -m "my statement for this commit"

Push commit to git server Push to the current branch:

$ git push


Push to a specific branch named branch_name:

$ git push origin HEAD:branch_name

List commits List all commits:

$ git log

List changes List changes with respect to the last commit:

$ git diff


List changes bewteen commits (changes of commit_2 with respect to commit_1):

$ git diff commit_1 commit_2
e.g.,
git diff 123bd9 4235be

Undo changes before adding/staging Undo all changes:

$ git checkout .


Undo changes in a file:

$ git checkout -- filename

Undo added/staged changes Undo a file addition:

$ git reset filename


Undo the addition command "git add .":

$ git reset

Download up-to-date repository Download the whole repository from git server:

$ git pull


Download a branch of a repository from git server:

$ git pull origin branch

Switch to a branch in a repository Switch to a branch named branch_name:

$ git checkout branch_name

Create a new branch in a repository Create a new branch locally:

$ git checkout -b new_branch_name


Push a new branch to git server:

$ git push origin new_branch_name

Delete a branch in a repository Delete a branch locally:

$ git branch -d branch_name


Push branch deletion to git server:

$ git push origin :branch_name

List branches in a repository List branches that have been checked out:

$ git branch

Replace existing commits with a new commit Remove commits Check out a branch and reset at the Nth commit removing N-1 commits from the latest commit:

$ git checkout branch_name
$ git reset HEAD~N

Create a new commit Add changes and commit as usual:

$ git add -A
$ git commit -m "my_statement"

Push a new commit to a branch Push to a branch named branch_name:

$ git push origin +branch_name

Merge two branches Merge a branch into another branch Check out a branch_into and merge branch_from into the branch_into:

$ git checkout branch_into
$ git merge origin/branch_from

Handle conflicts Keep files of branch_into:

$ git checkout --ours "filenames in branch_into"


Keep files of branch_from:

$ git checkout --theirs "filenames in branch_from"






발자취

2019-09-11 "키클 코딩랩 - 미국 공학박사 아빠의 코딩 연구소"로 이름 변경
2019-06-28 코딩 교실 공개
2019-03-18 코딩 교실 제작 시작

바로가기
About
Contact
Privacy Policy
강의목록
질문하기
처음으로