-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit_notes.txt
60 lines (45 loc) · 1.86 KB
/
Git_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
48
49
50
51
52
53
54
55
56
57
58
59
60
git rev-list --all | (
while read revision; do
git grep -F 'SWT.F2' $revision
done
)
/// revert , reset commit
git revert <mã_hash_commit>
git reset --hard <mã_hash_commit>
git reset : sẽ thay đổi HEAD (thay đổi mới nhất ở branch) về các commit khác
git reset --hard: với option --hard, sau khi chuyển về các commit khác, các commit sau đó sẽ bị mất. Tuy nhiên có thể sử dụnggit reflog để khôi phục lại.
git reset --soft: tương tụ nó sẽ yêu cầu Git chuyển về các commit khác, nhưng trạng thái staged và tất cả sự thay đổi của file sẽ được giữ nguyên.
///
///
Cherry pick được dùng để lấy một commit từ branch này và áp những thay đổi lên trên branch khác.
Để sử dụng cherry pick, bạn git checkout qua branch cần apply commit vào và thực thi lệnh: $ git cherry-pick <mã_hash_của_commit>.
///
///
git log foo.rb | grep "bar"
///
git grep <regexp> $(git rev-list --all)
///
To find which commits and which files a string was added or removed in:
git log -S'search string' --oneline --name-status
To see the diff of that
git log -S'search string' -p | grep 'search string' -C5
You can also do a regex search by using -G instead of -S.
// rename branch
git branch -m <newname> // rename the current branch
git branch -m <oldname> <newname> //rename a branch while pointed to any branch
/// github
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/mrviit/notes.git
git push -u origin master
///Find Git Repository URL
git config --get remote.origin.url
git remote get-url origin
git remote show origin
git remote -v
///Error
Cloning into 'xxx'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/xxxyyy.git/'
=> git config --global--unset credential.helper