-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_notes.txt
47 lines (47 loc) · 2.43 KB
/
my_notes.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
repository - warehouse. Has a .git file which is a version storage.
commit - game save; snapshot
working directory
stage - temporary storage for files to commit
fast-forward - make the main pointer point to the to-be-merged branch commit directly
- without which git creates a new commit
BRANCH EARLY AND BRANCH OFTEN
common branching practice: main (steady, to-be-published)
dev (for development, should keep in pace with remote)
bug (fix bug locally, usually not synced with remote)
feature (depends on whether you and colleagues work on it together)
if you and your colleague are working on the same file, but two different local branch corresponding to the same remote branch:
- git push orign <branch_name>
- if fails, the remote is ahead of your local.
- git pull to grab the newest commit from origin/dev
- merge locally to solve the conflict
- try again
no tracking information: no connection between specified local branch and remote branch
----- git commands to be reviewed -----
git init
git add <filename>
git commit -m "comment"
git status
git log <--pretty=oneline>
git reset <--hard> <HEAD^> //used to restore the last version
<HEAD> <file> //used to restore a committed change to stage (unstaging)
git reflog
git diff <HEAD> -- <readme.txt>
git checkout <--> <readme.txt>
ssh-keygen -t rsa -C "[email protected]"
git remote //load remote branch info
-v //same, but detailed
add origin [email protected]:your_github_username/your_remote_repo_name.git
rm origin //unbind local repo from corresponding remote repo, does not actually delete anything
git push origin master
git clone [email protected]:your_github_username/your_remote_repo_name.git
git checkout -b branch_name == git switch -c dev
dev origin/dev //create the corresponding local dev branch according to the remote origin/dev branch
git merge dev //on local branch main, merging local branch dev
--no-ff -m "merge with no-ff" dev //merge without fast-forward
git branch -d branch_name //delete
-D branch_name //delete by force
--set-upstream-to=origin/dev dev //establish the connection between local dev branch and origin/dev branch
git stash //stash current progress to return to a clean working tree
list //list stashes
add/drop
pop