-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit
More file actions
102 lines (77 loc) · 3.17 KB
/
git
File metadata and controls
102 lines (77 loc) · 3.17 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Git is a version control system
1. Easy file recovery
2. Who introduced an issue and when ?
3. roll back to previously state
- snapshot not difference
.git folder - project history - Saves snapshots
- Almost every operation are local
- git has integrity - checksum matching
- git generally only adds data
- As you make changes to your project, the value in the .git folder keep adding
Workflow:
Q:How to intialize a folder/git repository ?
- git init
- This is to allow git to track changes in the folder.
Q: How to add all files into the staging area ?
- git add --a
Q: git commit
This will take a snapshot of all the files
Q: How to change the commit author for one specific commit?
https://stackoverflow.com/questions/3042437/how-to-change-the-commit-author-for-one-specific-commit
git commit --amend --author="Gaurav Yadav <gary391@gmail.com>" --no-edit --> This is command to make the change
A-B-C-D-E-F with F as HEAD, and you want to change the author of C and D, then you would
1. git rebase -i <B-commit>
2. Identify the commit you would like to change in the terminal window
3. change pick to edit
pick 1fc6c95 Patch A
pick 6b2481b Patch B
pick dd1475d something I want to split
pick c619268 A fix for Patch B
pick fa39187 something to add to patch A
pick 4ca2acc i cant' typ goods
pick 7b36971 something to move before patch B
# Rebase 41a72e6..7b36971 onto 41a72e6
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
:wq
4. git commit --amend --author="Gaurav Yadav <gary391@gmail.com>" --no-edit
5. git rebase --continue
6. git push -f (Once done push all the changes) - Note if you do a regular push, it will not work.
https://www.youtube.com/watch?v=3LIr70uVZ_Q&ab_channel=TutorialTim
a. Download bare respository using - git clone --bare <Repository Name>
b. cd
c. execute the bash script
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="garyrao@bbc.com"
CORRECT_NAME="gary391"
CORRECT_EMAIL="gary391@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
d. git push --force --tags origin 'refs/heads/*'
e. remove the bare repository using rm -rf <repo>
Q:
Q: How to access multiple github accounts from one computer
### SSH KEYS
1. Generate separate SSH keys
ssh-keygen -t rsa -b 4096 -C "gary391@gmail.com"
save it as id_rsa_<name>