-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_github
More file actions
79 lines (58 loc) · 3.6 KB
/
git_github
File metadata and controls
79 lines (58 loc) · 3.6 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
Git
# version control. saves all changes done to a project and makes it possible to go back to previous versions.
# starting a new repository
git status
rm -rf .git
git status
git init
git status
git add .
git commit -m "Starting over"
git status
# deleting repository --> it can be deleted in browser or via command line
# after doing this we can no longer go back to any other commits
# if this happens we need to start a new repository
git log --pretty=oneline --> to see all the commits (ID's) from started projects until Extended greeting
git checkout --> when we make a mistake and want to revert back to the previous commit. This also mean that if there are things we didn't commit until this point, these changes will be lost when doing checkout
git checkout be0176 --> the first six letters in the ID. The ID allows us to look at different commits in the project.
git checkout master --> to get back to master brand.
git init
git reset --hard be017e --> to choose which one to be HEAD of the branch.
# uploading files to github
# create an account, a repository on github. Fill name, description, if it is to be private or public and if we want to add a README file.
# go to terminal
# go to the folder where you have your repository (ie. Desktop/Python)
git init --> creating repository within the folder
git remote add origin "link to repository on github"
git remote -v
git add . --> adds all new files to the repository. If we want to select certain files we can write the name of those files.
git commit -m "started project" --> record message about the commit (snapshot)
git commit -am "Extended greeting" --> can be any name we want to commit changes to projects we already added (with git add .).
git push origin master --> write username and password for github.
git remote show origin --> showing the url. Should look like this:
git+ssh://git@github.com/username/reponame.git
git remote set-url origin git+ssh://git@github.com/username/reponame.git --> if the url is not like the one above, you can change it by doing this
git push --set-upstream origin master --> this make the verification automatic so you don't have to write username and password every time you want to push a commit
NOTE: We can make many commits and then wait until the end of the session to use git push
git help --> a command to get more info about git commands
# to change default branch in github to the page of the specific respository ie. saliveja/python_crash_course
- click on Branch
- there is an option to delete the unwanted branch
# to create or delete a Personal access token
- go to Settings - Developer settings - PAT
# collaboration
- invite another user by in the repository going to Settings - Collaboration. Your invite will be send to the other users email and need to be accepted before you can continue.
- Make a folder where you want to store the collaborators repository
- open the terminal in the repository folder
# clone their project
git clone https://nameoftheirrepositoryasitisseeninthebrowser
git pull --> allow you to see changes
NOTE: you can add to the collaborators project just as you add to your own. You confirm with your own username and PAT
git log --pretty=oneline --> can also be used to see the collaborators total commits
git fetch --> download objects and refs from another repository
git config --global core.editor "geany" --> To make geany
git diff --> to see what has changed
git pull --rebase --> merging
git log --> to get out of this press q
git merge "strategies" --> If we have two branches that we need to merge
# people who are not added to github, can make forks and make pull request (they cannot make own changes)