summaryrefslogtreecommitdiffstats
path: root/cheats/git.cheat
blob: 957239bacf40ab6f2565fa30146932b2fbb01292 (plain)
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
% git

# Set global git user name
git config --global user.name <name>

# Set global git user email
git config --global user.email <email>

# Initializes a git repository
git init

# Adds a remote for a git repository
git remote add <remote_name> <remote_url>

# Checkout to branch
# Change branch
git checkout <branch>

# Displays the current status of a git repository
git status

# Displays the changes made to a file
git diff <filename>

# Stages a changed file for commit
git add <filename>

# Stages all changed files for commit
git add .

# Saves the changes to a file in a commit
git commit -m <message>

# Pushes committed changes to remote repository
git push -u <remote_name> <branch_name>

# Pushes changes to a remote repository overwriting another branch
git push <remote_name> <branch>:<branch_to_overwrite>

# Overwrites remote branch with local branch changes
git push <remote_name> <branch_name> -f

# Pulls changes to a remote repo to the local repo
git pull --ff-only

# Merges changes on one branch into current branch
git merge <branch_name>

# Displays log of commits for a repo
git log

# Displays formatted log of commits for a repo
git log --all --decorate --oneline --graph

# Clear everything
git clean -dxf

# Sign all commits in a branch based on master
git rebase master -S -f

$ branch: git branch | awk '{print $NF}'