-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0-git
More file actions
71 lines (47 loc) · 1.93 KB
/
0-git
File metadata and controls
71 lines (47 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Git Cheat Sheet
Basic Commands:
git init Initialize a new Git repository
git clone <url> Clone a repository from a URL
git add <file> Add a file to the staging area
git add . Add all changed files to the staging area
git commit -m "message" Commit changes with a message
git status Show the status of the working directory and staging area
git log Show commit history
git diff Show changes between commits, the working tree, and the
staging area
Branching & Merging:
git branch List all branches
git branch <branch> Create a new branch
git checkout <branch> Switch to a different branch
git checkout -b <branch> Create and switch to a new branch
git merge <branch> Merge a branch into the current branch
git branch -d <branch> Delete a branch
Remote Repositories:
git remote -v List remote repositories
git remote add origin <url> Add a remote repository
git push origin <branch> Push a branch to a remote repository
git pull origin <branch> Pull changes from a remote repository
git fetch origin Fetch changes from a remote repository without merging
Stashing:
git stash Stash changes
git stash pop Restore stashed changes
git stash list List stashed changes
git stash drop Delete a stashed change
Other Useful Commands:
git revert <commit> Revert a commit
git reset --hard HEAD Reset the working directory to the last commit (use with
caution!)
git rm <file> Remove a file from the repository
git help <command> Get help for a specific command
Ignoring Files:
Create a .gitignore file in the root of your repository to specify files and
directories to ignore. For example:
*.log
temp/*
Common .gitignore entries:
/target/
/build/
*.class
*.pyc
Note: Replace <file>, <branch>, and <url> with actual file names, branch
names, and URLs. Always commit your changes before switching branches.