Wecode day 10

Michael Minchang Kim·2020년 4월 30일
0

wecode

목록 보기
13/22

Git

Git is a version control system also created by Linus Torvals. It is used to manage code version between a group of software developers.

1. File status

When using Git to version control files, the files will be in one of the three states

a. Committed

Committed is a state in which the code fixes are saved in git. This action of saving code is called committing.

b. Modified

Modified files are literally modified files. If a file's code is changed but not committed yet, the file is in a modified state.

c. Staged

The staged state is a state between committed and modified. A staged file is a file that is modified but not commited yet. It is saved and marked as a file to be commited. Since committing happens when the code is fully developed, the staged stage exists to save a modified file to be reviewed again.

2. Basic Git Commands

a. git init

This command turns the project into a got repository.

b. git add

Move modified file into staged status

c. git commit

Commit the staged file.

d. git diff

Check what edits have been apllied

e. git status

Check what status files have currently

f. git log

Shows you the history of commits

g. git rm

remove file from git repository

h. git mv

Used when moving a file within git repo. Usually used when renaming

i. git branch

Used to create a Branch
The git branch command will show you a list of branches.

j. git checkout

Used to move between branches.

3. How git works

a. How to intialize git

    git config --global user.email “wlsxo2112@naver.com”
    git config --global user.name “Kjintae”

b. How to connect repository to git

    git init
    git add -A
    git commit -m “first commit”
    git remote add origin https://github.com/kingofahn/JavaStandardEdition.git
    git push -u origin master

c. How to make a branch

	git  branch <feature/name>

d. Move between branches

How to move between branches

git checkout -b <branch_name>

The -b moves user to the branch made.

Check out a branch from the master. After editing the branch

Git conflicts

Since multiple people work on the same file, conflicts will happen if the master file gets merged with another user's update.
When this happens, the pull request will show that there is a conflict.
In this case, use the git pull origin master command from within the branch and edit the file in conflict.
Add, Commit and push the edited version and the conflict will be solved.

profile
Soon to be the world's Best programmer ;)

0개의 댓글