-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask1-answer.text
More file actions
116 lines (54 loc) · 4.12 KB
/
Copy pathTask1-answer.text
File metadata and controls
116 lines (54 loc) · 4.12 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
103
104
105
106
107
108
109
110
111
112
113
114
1. Explain the purpose of the following Git commands:................................................................................................................................................................
a) git status:
shows the current changes (files changed) on repository (or the branch the code in it) that have been added but not yet published notice us if we need to cancel changes
b) git init:
make the local folder as git repo so we can link with a remote repo or run the git commands in it
c) git commit:
it works like a recorder to put the changes in the repo changes history that could be a reference point ( know by the message of that commit ) to see later or revers the code to that point
d) git push:
publishing the commited changes to the online git repo like Github or GitLab so the other people can see it
2. Ahmed's claim about git add:.......................................................................................................................................................................................
I disagree with Ahmed's statement that there's no need for git add. because:
if we don`t add the files to staging area it could be harder to track the changes later , and in case we did some forgotten modification it will make a missy status in the code later that files will be harder to revert .
3. Code hosting providers:............................................................................................................................................................................................
a) Two popular code hosting platforms besides GitHub:
GitLab
Bitbucket
b) Key features of code hosting providers:
Version control infrastructure (repositories, branches, tags)
Collaboration tools (pull/merge requests, code reviews)
Access control and permissions management
Issue tracking and project management
CI/CD integration for automated testing and deployment
Documentation and wiki capabilities
Analytics and reporting on project metrics
c) True or False: A team can collaborate without popular code hosting providers by setting up a self-hosted server.
True. Teams can set up self-hosted version control servers using solutions like GitLab Community Edition, Gitea, or a custom Git server. This provides control over infrastructure but requires additional maintenance and security considerations.
4. The -u flag in git push -u origin main:...............................................................................................................................................................................
The -u flag sets the upstream tracking reference between the local branch (main) and the remote branch (origin/main), after using this flag once, subsequent git push and git pull commands can be used without specifying the remote and branch, as Git remembers this association. This simplifies workflow by reducing command verbosity.
Practical Part: Creating a Local Git Repository and Linking it to GitHub via SSH
Step 1: Generate SSH Key Pair...................................................
# Generate a new SSH key if none exists
ssh-keygen -t ed25519 -C "your_email@example.com"
Step 2: Add SSH Public Key to GitHub............................................
bash# Display and copy your public key : to copy it the right form so the git hub accept it
cat ~/.ssh/id_ed25519.pub
Loging to GitHub and go to Settings → SSH and GPG keys → New SSH key
Paste my public key in the "Key" field
write the title
Click Add SSH key
Step 3: Create a Local Git Repository...........................................
# Initialize Git repository
git init
# Stage and commit the files
git add .
git commit -m "first commit"
Step 4: Create a GitHub Repository..............................................
# Go to GitHub and click New repository
# Test the connection
ssh -T git@github.com
Step 5: Link Local Repository to GitHub via SSH..................................
# Add the remote repository using SSH URL
git remote set-url origin git@github.com:Hadi-Badran/Github-Course-Task1.git
# Push the local repository to GitHub with upstream tracking
git push -u origin main