-
Notifications
You must be signed in to change notification settings - Fork 0
/
Git_Notes.text
80 lines (55 loc) · 4.49 KB
/
Git_Notes.text
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
git branch: Shows what branch your on.
git checkout Staging: Git checkout changes the branch your on. Before I was on branch main and after runing this
I am now in the staging branch. And it also changes all your local code to that branch as well.
git checkout -b lyle: This creates a new branch named lyle.
git pull origin branch-name: Pulls the code from the branch given and replaces the local code with it. This is often
used instead of git merge for its simplicity. So you can checkout into a branch and git pull another branch then git
push to the new branch to merge the two. Look bellow to undo a pull.
git push --force: Be careful this will force a push request even if it wasn't meant to. The reason I use it is If
I fucked up and for some stupid reason can't fix an error, I can revert to an old commit, change the code without
fucking it up again, and force git to push my old edited commit as head. And this will replace all the newer commits
ahead of this older edited commit with the edited older commit. watch the fuck out with this!
git reset --hard bc7bb49ad2d42f68f19f0bdd6d4af48b3675b170: before every pull request you are required to commit your
branch first. If you wish to reset your application to the local code before your pull request, run this with the last
commit you made before pulling.
git fetch + git merge is literally the same thing as git pull!
git clone https://github.com/adri.....etc: Clones the git repo given. You may need to rap the url in purenthasies "".
If you clone your own repo and you are signed in to git on the browser then it will automatically set your credentials
for you.
git remote -v: This shows http version of the directory you are pushing to.
git remote set-url --add --push origin https://github.com/a......etc: This changes the git repository you are to
pushing to, to the one given. git remote add origin https://etc.....git: Also adds a new you repository url.
git remote rm origin: This removes a repository's url you are pushing too. Urls have a name of origin, heroku, and others.
Adding orgin, like in the example, will remove all the urls that are using origin.
git push --set-upstream origin branch-name: This sets your upstream to a branch. Comonly needed when first pushing
after cloning a git repo.
git merge origin branch-name: This will merge the branch I am on with the branch name given. Make sure to git commit
first and be carfule with this command. Doing the other option given above in git pull is also available. Actualy I'm
just talking shit, it's easy!
git reset --merge: Resets a merge back to the original state.
git restore .: This will delete all changes back to the previous commit. Be warned. Don't loose your work.
git fetch: Refreshes your branches so that git is up to date with your online aplication. Like if a new branch was
created recently, git fetch will fetch that data so that your local aplication is up to date with your online aplication.
git log: Shows your commit history. Each commit will give you a name and a commit id.
Login to github with the terminal:
git config --global user.name "your_username"
git config --local user.name "your_username"
git config --global user.email "[email protected]"
git config --local user.email "[email protected]"
git config --global credential.username "your_username"
git config --local credential.username "your_username"
git config --global --list
git config --local --list
and --local is for your local project and --global is for all projects on your machine
You'll be prompted for your password after your next git push
If the git remotes are wrong it will fail.
git config --local --remove-section branch.main: Will remove the branch.main sections out of gits local config. It's for
fixing a git error that involves having 2 versions of these branch.main sections when you just need 1
gh auth login: Login to github with GitLab in the terminal. A certain git package thing will need to be downloaded for this to
work. And it isn't working. Fuck !
git checkout commit-id-12feg3435: To switch to an old commit. and then: git switch -c <new-branch-name> to retain your
new commits in a new branch!
git commit -a -m "your commit message!": git add .'s and also will git commit with a message at the same time!
Deploying a backend or website to heroku with github guide: https://devcenter.heroku.com/articles/git
To deploy the master branch or main branch run: git push heroku main
To push a different branch to heroku that isn't the master or main branches, run: git push heroku production:master