TIL36 - Git & Github Intro

Peter D Lee·2020년 9월 23일
0

Git & Github

목록 보기
1/2
post-thumbnail

What is Git?

--> A version control system
Git allows a folder to be tracked 24/7, track any changes made to the folder and create and control versions of the folder

What is Github?

--> Where you can save and manage git repositories

How to use Git

1. On the Local Level (Git)

Initializing

  • Open terminal, and cd to the the directory that you would like to start tracking
  • when you are in the directory that you want to start the version control, enter git init to initialize git --> this creates a .git folder inside the directory
  • after this step, this directory will be tracked and you can now start commiting any changes made to the folder

Checking status

  • To check the status of the directory, you can use the command git status, this will show any changes made to the directory after the last commit, including new file creation, file edits, and file removals. If there is no change, it will say there is "nothing to commit, working tree clean"

Adding files to the staging area

  • After you have made new changes, you can use git add to add the files with changes to the staging area, after which you can commit the changes to git --> You can enter git add <file name> to add individual file to the staging area, or git add . to add all the files in the directory. The . indicates "all"

Making the commit

  • Now you can commit the changes. To commit, you use the command git commit. When you commit, you must(should) add a message indicating which changes are made. This should be a brief explanation of the commit you are making. adding a message can be done by adding -m "description" to git commit command. For example, if you want to commit with the message "initial commit", you would enter git commit -m "initial commit"
  • After making the commit, you can check the information of the commits you have made by using the command git log. This will show a list of commits you have made with basic information such as the commit code, author, and date/time of commit

2. Linking to Remote (Github)

  • First log in to your Github account on your browser
  • Create a new repository
  • On your local terminal, enter git remote add origin <github repository url + .git> --> At the end of the url, you should add '.git'. For example, if the remote url is https://github.com/username/repository1, you should enter the command git remote add origin https://github.com/username/repository1.git
  • These commands are available to copy and paste from your github account when you first create the new repository
  • After adding remote, now the local repository is linked to the github repository
  • Now you can push and fetch to update new commits from local and remote repositories to be synced
  • To push local commits to remote, use the command git push -u origin master

2개의 댓글

comment-user-thumbnail
2023년 4월 6일

who need help improving their coding skills butterfly locs, daily game solve cross

답글 달기
comment-user-thumbnail
2023년 4월 30일

MadisonDeed crediblebh

답글 달기