-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_basics.txt
More file actions
124 lines (94 loc) · 4.03 KB
/
Copy pathgit_basics.txt
File metadata and controls
124 lines (94 loc) · 4.03 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
115
116
117
118
119
120
121
122
123
124
1)> Basic Termonlogy
====================
- Git is like a really epic save button for your files and directories. Officially, Git is a version control system.
- commits: snapshots of --> structure of CWD & contents of files in a specific moment in time.
- repository: a timeline of commits and branches (A repository contains all project files, including the revision history).
- branches: new development paths that we can follow as long as we like without missing up original project.
- master branch: the main branch of the project.
- pull requests: a report of all changes made in a branch.
- cloning: downloading the repo from github to work-on (same repo == same id).
- pushing: uploading the repo to github.
- forking: copying the repository from one account on github to another (entirely new repo == not the same repo == different ids).
2)> Important Notes:
====================
= Git is distributed (locally enabled), version contorl can happen on local computers by cloning repositories & if a server-comonenet is needed for collabrtion --> github can be used.
=
*Note: in order for pull requests on the same repo to work --> the admin must be cloning the repo (up to date) && the co-developer must push changes to remote repo (up to date)
3)> Basic Git Commands
======================
*Note: for <file_name> you can add wild cards: '.', '*.html' ...etc.
- git local configurations:
---------------------------
-> The username and email: they are not credentials for any git/github sites -> they are local records to give credit for work done using git
$ git config --global user.name "<username>"
$ git config --gloabl user.email "<user@example.com>"
- cloning a repository:
-----------------------
$ git clone <repo url.git>
- initializing a repository:
----------------------------
$ git init [if <repo name> was added it's gonna create a repo from ..][if not --> it is gonna create a repo from current dir]
- adding a remote repository:
-----------------------------
$ git remote add <repo name - local> <repo url>
- pulling latest from a remote repository:
------------------------------------------
$ git pull <repo name>
- adding .gitignore file:
-------------------------
.gitignore is a file that contains all types of files that we don't want to add to our git repo.
- adding files to stage:
------------------------
$ git add filename.ext
- unstaging a file:
-------------------
$ git rm --cached <file_name>
- commiting changes to repository (taking a snapshot):
------------------------------------------------------
snapshots are for selected files in the stage step "only".
$ git commit -m "commit message"
- pushing to remote repository:
-------------------------------
*Note: a remote connection must be established first using ssh or https
$ git push
- switching branches:
---------------------
$ git checkout -b <branch-name>
$ git checkout master
- ignore changed files:
-----------------------
$ git update-index --assume-unchanged <path-of-modified-file>
- add to .gitignore:
--------------------
# add the following line to .gitignore
/Hello.class
# This will exclude Hello.class from git. If you have already committed it, run the following command:
$ git rm Hello.class
# If you want to exclude all class files from git, add the following line to .gitignore:
*.class
for more info: https://stackoverflow.com/questions/4308610/how-to-ignore-certain-files-in-git
***
1 ) Examples:
***
ramoun: $ git checkout master
ramoun: $ git commit -a -m "my new logo"
ramoun: $ git push
tito: $ git checkout -b titoslogin
tito: $ git commit -a -m "adding a login page"
tito: $ git push origin titoslogin
#merging ramoun's and tito's work
ramoun: $ git pull
ramoun: $ git merge titoslogin
#Documentation
$ git add -p my report.markdown
$ git commit -m "Added latest stats"
$ git log --graph --decorate --abrev-
commit --all --pretty=oneline
# -----
# These notes represent the understanding of the topic by (R}AM#UN>)
# These notes are FULLY:
# -> Written By (R}AM#UN>)
# -> Coded By (R}AM#UN>)
# -> Produced By (R}AM#UN>)
# -> Created By (R}AM#UN>)
# -----