-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-instructions.css
115 lines (60 loc) · 4.9 KB
/
git-instructions.css
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
/*On Bluehost ftp manager, don't just delete ftp account, it will delete all files in this accounts directory. And it will brake .git folder. */
GIT INSTARACTIONS
git checkout <branch-name>
git add /*adding files to the staging area*/
git add . /*add all files to the staging area*/
git add password* /*adding files that begins with a word password*/
git pull origin master /*getting all files from master branch*/
git status /*see status of all files*/
git add file_path
git rm --cached filename /* untrack files in git */
git commit -a /*commit only those files that have been already committed*/
git commit -m "your message"
git push /*it is pushing all info from one branch to another. or from computer to a server (git push origin master)*/
vim .gitignore /*creating text file with a list of files you want to ignore, and not to commit them accidentally*/
git diff SomeFile /*shows what changes where made to this “SomeFile” file*/
git diff --staged SomeFile /*git diff — cached SomeFile*/ /*shows what changes where made to this “SomeFile” file if it is in staging area*/
git diff HEAD README /*shows what changes where made in staging area and working area since last commit*/
git diff 7e3119c SomeFile /*shows what changes where made to SomeFile since this commit (7e3119c)*/
git log /*shows the list of commits you made*/
git log --stat /*shows the list of commits with additional information*/
git log --oneline /*shows short info of all commits you have done*/
/* ============= Branching ====================== */
git branch /*list of all branches*/
git branch BranchName /*create a new branch*/
git checkout BranchName /*switch to that branch*/
git checkout -b BranchName /*creating and switching to this branch simultaneously*/
git branch -d the_local_branch /*to delete local brach*/
git push origin --delete branch_name /*delete remote branch*/
git log --oneline —graph —all —decorate /*shows all commits in all branches*/
alias gl="git log —oneline —all —graph —decorate" /* creating alias (shortcut)*/
git merge BranchName /*merging BranchName with branch you are currently on*/
git rebase /*don’t know what to say*/
git push -u origin master /*adding all files and changes from local to github repository*/
git push -u origin feature_branch_name /*copy local branch to remote*/
git reset --hard HEAD^1 /*will take you back one commit from what you pulled. If you want it back to the state it was in before you pulled, use git reset --hard HEAD@/*1*/. The @(1) tracks where the head was at before the last operation that changed it in your local repo, so it will go back several commits if several were pushed before you did your pull. Also see git reflog to show the entire list.*/
git remote -v /*will show you what your remotes are*/
git branch -u origin/master /* set remote branch to track local branch ( link - http://stackoverflow.com/questions/520650/make-an-existing-git-branch-track-a-remote-branch )*/
git push --set-upstream origin master /* (sometimes doesn't work) set remote branch to track local branch (To push the current branch and set the remote as upstream, use)*/
So, we need to make an UPSTREAM remote
Something you can pull the latest code from
do this:
git remote add upstream git@github.com:imoutdoors/IMOMags.git
Then to fetch the latest code from github you type:
git pull upstream master
git remote add fox git@github.com:foxjbowden/IMOMags.git /* add one more remote from different user account. fox - any_name_you_want to call your remote. foxjbowden - user name. IMOMags.git - git repository */
/* =========================================================================================
Setting up ssh keys. Cloning repository from Github
========================================================================================= */
/*First install wordpress in your project folder*/
/*You can skip step 1-7 if you have ssh key configured*/
1. git init
2. git config --local user.name <your github username>
3. git config --local user.email <your github email>
4. ssh-keygen -t rsa -C ‘your github email’
5. enter passphrase <yourpassword> /*can be any password you choose*/
6. ls -al ~/.ssh /*check if there is id_rsa.pub file , than cd to directory where id_rsa.pub is located. */
7. cat id_rsa.pub /*copy the output and paste it in to your github account > ssh keys > add ssh key> */
8. git clone <your forked repo> /*example : git clone git@github.com:artre/seepolls.git*/
/*After you clone repo, it may clone repo with a project folder. Cut everything from project folder and paste it in to your current project folder.*/
9. git remote add production git@github.com:Seepolls/seepolls.git /*add ‘production’ (usually called ‘upstream’) repo. You can pull from production repo, but you can’t push to it. You can push to it only if you have https://github.com/Seepolls username and password.*/