-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit&GitHub.txt
157 lines (107 loc) · 5.71 KB
/
Git&GitHub.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
git --help
Open Terminal in Project
git init > create local git repo
git add . > add files to repository
git commit -m "First Commit" > commits that files with a message
git branch -M main
git remote add origin https://github.com/AyushKadbe/Startup_Namer_Flutter > link to github repository
git push -u origin main > pushes Local repository of project to the GITHUB hosted repository(empty bydefault)
git push -f origin main
git push --set-upstream origin branchName1
//There are many branches created for a project on a device.
//Then the branchName1 will be pushed to github as a new branch other than main branch.
------------------
COMMIT unstaged work on current branch to a new branch
git checkout -b your-new-branch
git add <files>
git commit -m <message>
------------------
Push another branch of same project
git init
git add .
git commit -m "First Commit"
git branch -M myapp
git remote add origin https://github.com/AyushKadbe/
git push -u origin myapp
git push -f origin main
git push --set-upstream orgin myapp
--------------------
Github Sub Module:
It is just like a Repository embedded inside another repository while the embedded repository/Submodule redirects to its PROJECT Repository
Parent Repository as well as Separate Repository of Project must be creted on Github.
Open terminal of Git Parent Repository in VScode
git submodule
┌─[infinitex@infinite]─[~/Documents/VScode/Flutter/Flutter-Notes-Programs]
└──╼ $git submodule add https://github.com/AyushKadbe/Startup_Namer_Flutter
git status
git add .
git commit -m "Add submodule"
git push (push these changes to the Parent repository)
https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github
===================================================================
git switch focuses on branches while git checkout targets commits
git switch main
git switch multi_tab
===================================================================
Working Directory: Directory of Project you are currently working on
Staging Area: A Project or directory has many files, so you can't commit all files at once due to some errors in some file,
So you work on any file and add it staging area after editing/testing/debugging.
After collections of enough/required updated files in staging area, these file are commited to the Local Repository on Your Computer & Taken as a BackUP.
Now after that you can push that file to Remote Repository on Server which hosts all code while different file/different directories are accessed and modified by other people,
who clone that Repository in their local Computer.
Initialize A Project
git init
Check status like commits
git status
Add a edited single file for single feature of a Full Project tested in IDE or Code editor to the Staging Area
git add <file> for checkpoint
Git Commit: comite that Edited Files from Staging Area to Local Repository LOCAL BRANCH on own Computer
git commit
git commit -am""
a for skipping staging area and m for message
Unstage
git rm --cached <file_name>
New Branch
git branch <branch_name>
Swtich Branch
git checkout<branch_name>
Git Merge: merge a Working BRANCH to the LOCAL BRANCH on the Computer after testing&Debugging the Code
git merge<branch_name>
Git Fetch: Merge Change of LOCAL BRANCH to MAIN MASTER BRANCH after reviewing the code
git fetch
Git Pull: Merge Changes of Git Local/Git working BRANCH to MASTER BRANCH Git Remote Repository
Now everyone do not have access to MERGE TO MASTER BRANCH.
They work on WORKING DIRECTORY > THEN ON LOCAL BRANCH on their PC
Then they put a GIT PULL request to CODE REVIEWER, who review & analyse the Person's LOCAL REPO. CODE & after succesfull code, he/she MERGES
that LOCAL REPO. CODE to MAIN BRANCH.
Access to merge to MAIN MASTER BRANCH is controlled ALTHOUGH LOCAL CLONES of REPOSITORY is still maintained on the LOCAL COMPUTER OF COLLABORATOR.
============================================================
How to fork your own repository on GitHub ?
1. Create a new repository for your fork
On GitHub, create your new (empty) repository https://github.com/new, using the default settings. This will be your forked repository.
2. Clone your fork
Make a local copy of your new forked repository using git clone.
git clone https://github.com/<username>/<forked-repo>.git
3. Add your original repository as an Upstream Remote
Add your original repository as an upstream remote in your forked repository. Doing this will allow you to pull in changes from your original repository to your forked repository.
cd <forked-repo>
git remote add upstream https://github.com/<username>/<original-repo>.git
4. Update your fork
Update your fork with all the changes from your original repository using git pull.
git pull upstream master
5. Push
When you are done, simply push your new fork back into GitHub.
git push origin master
--------------------
Github Sub Module:
It is just like a Repository embedded inside another repository while the embedded repository/Submodule redirects to its PROJECT Repository
Parent Repository as well as Separate Repository of Project must be creted on Github.
Open terminal of Git Parent Repository in VScode
git submodule
┌─[infinitex@infinite]─[~/Documents/VScode/Flutter/Flutter-Notes-Programs]
└──╼ $git submodule add https://github.com/AyushKadbe/Startup_Namer_Flutter
git status
git add .
git commit -m "Add submodule"
git push (push these changes to the Parent repository)
============================================================