- Version Control
- Local Version Control Systems (RCS)
- Centralized Version Control Systems (SVN)
- Distributed Version Control Systems (Git)
- Installation
- Environment Setup
-
Learn Linux Commands
cd
: Change directory.cd ..
: Move up one directory level. Usecd
to go directly to the default directory.pwd
: Display the current directory path.ls
(ll
): List all files in the current directory.ll
provides more detailed information.touch
: Create a new file. For example,touch index.js
creates a new file namedindex.js
in the current directory.rm
: Delete a file. For example,rm index.js
deletes the fileindex.js
.mkdir
: Create a new directory. For example,mkdir new_folder
creates a directory namednew_folder
.rm -r
: Delete a directory. For example,rm -r src
deletes the directorysrc
.mv
: Move a file. For example,mv index.html src/
movesindex.html
to thesrc
directory. Ensure the source and target directories exist.reset
: Reinitialize and clear the terminal.clear
: Clear the terminal screen.history
: View the command history.help
: Display help information.exit
: Exit the terminal.#
: Used for comments.
-
Configuration
-
-
Basic Theory
- Working Areas
- Local
- Working Directory: The workspace where files are dited. It contains the files currently being worked on.
- Repository (or Local Repository): A secure storage area for data, containing all the versions of files you have committed. The HEAD pointer references the latest version committed to the repository.
- Staging Area (Stage/Index) A temporary area for storing changes. Essentially, it is a file that holds information about the files that are about to be committed.
- Remote
- Remote Repository
- Local
- File States
- Untracked
- Unmodified
- Modified
- Staged
- Working Areas
-
File Operations
-
View File States
-
Ignore Files (
.gitignore
).txt # Ignore all files ending with .txt
!lib.txt # Except for lib.txt
/temp # Ignore the temp file only in the project's root directory, but not in other directories
build/ # Ignore all files in the build/ directory
doc/.txt # Ignore doc/notes.txt but not doc/server/arch.txt
-
-
Basic Workflow
-
Other Operations
- List Branches
- Local Branches
- All Remote Branches
- Create a New Branch
- Stay in Current Branch: git branch [branch-name]
- Switch to the New Branch: git checkout -b [branch]
- Merge Branches
- git merge [branch]
git init # Initialize a new Git repository
git status # Check the status of the working directory
git add <file_name> # Stage changes to a file
git add . # Stage all changes in the current directory
git commit -m "message" # Commit staged changes with a message
git log # View commit history
git diff # Show differences between working directory and staging area
git remote add origin <url> # Link a local repository to a remote
git remote -v # List all remotes
git push origin <branch> # Push changes to a remote branch
git pull origin <branch> # Pull changes from a remote branch
git clone <url> # Clone a repository to your local machine
git branch # List all local branches
git branch <branch_name> # Create a new branch
git checkout <branch_name> # Switch to a branch
git checkout -b <branch_name> # Create and switch to a new branch
git merge <branch_name> # Merge a branch into the current branch
git branch -d <branch_name> # Delete a local branch
git push origin --delete <branch> # Delete a branch in the remote repository