-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.txt
84 lines (65 loc) · 3.47 KB
/
git.txt
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
71
72
73
74
75
76
77
78
79
80
81
82
83
1. To use git with emacs, first put
export EDITOR=emacs
in your ~/.bash_profile file. Optionally add
source /usr/lib/git-core/git-sh-prompt
export PS1='\w $(__git_ps1 [%s])> '
2. Then use a command like one of the following:
git clone ssh://$USER@cascade.math.ualberta.ca/git/doc
git clone https://github.com/vectorgraphics/asymptote
git clone git@github.com:vectorgraphics/asymptote
git clone https://github.com/dealias/fftwpp fftw++
git clone https://github.com/dealias/protodns
to make a new working directory for the project in the current directory.
The most useful git commands are
git fetch (updates your local repo from remote repo)
git merge (merges updates in your local repo to your working directory)
git pull (equivalent to git fetch followed by git merge)
git add FILE (queue FILE to add to local repo)
git commit -a (commits changes to local repo)
git push (updates remote repo with changes in local repo)
git diff (identifies changes in your working directory)
git status (describes current state)
git log (show change log)
git ls-files FILE (show tracked files)
git remote -v (show remote url)
git show HASH (show commit changes for commit HASH)
git blame FILE (show author of last commit for each line of FILE)
git checkout FILE (restore FILE from local repo, losing changes)
git checkout BRANCH -- FILE (restore FILE from local BRANCH, losing changes)
git branch NAME (create branch NAME)
git checkout NAME (checkout branch NAME)
git checkout -b NAME (equivalent to above two commands)
git branch (list local branches)
git branch -d NAME (delete local branch NAME)
git push origin :NAME (delete remote branch NAME)
git cherry-pick COMMIT (merge specific commit from another branch)
git checkout @~1 (go one step back in history)
git merge --squash BRANCH (merge and squash commits from branch BRANCH)
git rebase -i HASH (squash commits since HASH)
git reset HEAD~1 (remove last commit from local repo)
git reset --hard (abandon all changes to local repo)
git reset HEAD^ --hard (delete last commit from local repo and abandon changes)
git push --force-with-lease (conditionally push changes to most recent commit)
git fetch origin pull/2660/head:links (fetch pull request 2660 as branch links)
git remote add cascade ssh://cascade.math.ualberta.ca/git/asymptote
git pull cascade
git difftool HASH^ HASH (diff commit relative to its parent)
git log --oneline --decorate (show compact change log with tags)
git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | bash -xfs (pull all branches)
git config --global pull.rebase true (improve git pull synchronization)
git config --global checkout.defaultRemote origin
Create a GitHub repo from local repo:
gh repo create
What would you like to do? Push an existing local repository to GitHub
Path to local repository .
Repository name dealias/dealias
Description Development of dealiased FFT-based convolutions
Visibility Private
Created repository dealias/dealias on GitHub
Add a remote? Yes
What should the new remote be called? upstream
Added remote git@github.com:dealias/dealias.git
Would you like to push commits from the current branch to "upstream"? Yes
java -jar ~/bin/bfg-1.14.0.jar --delete-files vort.mpg
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git remote set-url origin git@github.com:dealias/dealias