🤓
Thomas lab
Git&Github
Git&Github
  • Fetching & Pulling
  • Git alias
  • Git & Github : What is in .git ?
  • Git Rebase
  • Git reflog
  • Git Stash
  • Git tags
  • Git Workflow(Collaboration)
  • Quick High-Level
  • Git diff
  • Git installer
  • Reset & Revert commit
  • Github Collaborators
  • Github Basics
  • Introducing Git
  • Merging Branch
  • How to use multiple account
Powered by GitBook
On this page
  • Conceptual Overview
  • Repository
  • Committing Git
  • The basic git workflow
  • Git first command
  • Our Actual first fit Commands
  • From now on git will manages it
  • what is untracked ?
  • Git commit
  • Git ignored

Quick High-Level

Conceptual Overview

Repository

A Git "Repo" is a workspace which tracks and manages file within a folder

Anytime we want to use Git with a project , app, etc we need to create a new git repositoy. We can have as many repos on our machine as needed . all with separate history and contents

Committing Git

Committing making a commit is similar to making a save in a video game . We're talking a snapshot a git repository in time

When saving a file , we are saving the state cuar a single file . With Git , we can save state of mutiple files and folders together

The basic git workflow

Work on stuff ( make new files , edit files , delete file , ect ) =>

Add Changes (Group specific changes together , in preparation of committing )

Commit(Commit everthing that was previously added)

Git first command

git status

git status gives information on then current status of a git repository and its contents

It is very useful , but at the moment we don't actually have any repos to check

if your try it . We will receivce message

Our Actual first fit Commands

git init

Use git init to create a new git repository . Befor we can do anything git-related , we must initalize a repo first ! This is something you do one per project , initialize the repo in the top level folder containing your project

after use git init git tracks a directory and all nested subdrectiories

From now on git will manages it

after create foler .git with command-line git init . Try marking a new file in reposiory ,and then run git status,You'll see that git noticed the file , but it is untracked

what is untracked ?

I have three status : "working directory - Staging Area - Repository "

Untracked : message as git will listen all file changes and it inside status working directory . if you create a new file or edit file , git will listen , notice a change , git will add files in stauts 'Working directory'

Adding

use this command-line if you want to add some file

git add file_name_1 file_name_2

We use the git add command to stage changes to be commited .

It's away of telling git , "please include this change in our next commit "

after your add , git will give all files in status Staging Area with message tracked

Git commit

git commit -m "message your want commit in repository

With command-line git commit . Git give add commit in status Repository Area . It look like snapshot or endpoints . endpoints will helps us back if we want

Case 1 : Sometime your add missing files after your commit . How to add file when you commited ?

Step 1 : Add files forgot . git add filename_forgot

Step 2 : use command-line git commit --amend

after use git commit --amend . git group all file in status Staging Area give for commit nearest

Case 2 : change commit nearest

if your want modify commit nearest .Your can use command line

git commit --amend -m"Message your want update "

Git ignored

Sometime we don't want push any file to git repository , example as key , password , etc...

we can do it with ignore file

Step 1 : create file .gitignore

step 2 : list add patch files inside file .gitignore

some syntax

- fileA will ignore files named fileA
- folderA will ignore files named folderA
- *.js will ignore any files with the .js extension
PreviousGit Workflow(Collaboration)NextGit diff

Last updated 8 months ago