Repository navigation
Expand file tree
/
Copy pathgit
More file actions
52 lines (39 loc) · 1.74 KB
/
Copy pathgit
File metadata and controls
52 lines (39 loc) · 1.74 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
# one time config for your git account
git config --globel user.email "someemail@whatver.com"
git config --global user.name "john citizen"
git config --global credential.helper cache
git config --global credential.helper "cache --timeout=3600"
git config --global core.editor "vim"
# create another local git repo
cd /some/project/folder && git init
# add, remove and manipulate files in your local repo
git add somefile
git status
git rm anotherfile
git diff
git add *
# commit changes to your local repo
git commit -m "some comment"
# configure your local git repo to talk to remote git repo
git remote add origin https://github.com/maviharjit/somerepo.git
# push your changes to remote repo
git push -u origin master
# to make a local copy of git repo. do some local work. sync your repo with remote and push it
git clone http://github.com/maviharjit/someotherrepolgit
# git pull = git fetch + git merge
git pull
git push -u origin master
# OMG. i pushed something that i dont want world to see
# relax. reset to the last known good commit and force git push
git log
git reset --hard <hash for the commit where you want to go. the one before the mistake(s)>
git push -f origin master
# OR. if you just want to get rid of the last n pushes. e.g 2
git reset --hard ~2
git push -f origin master
# i want to reset to a past commit but dont want to lose local changes that i worked hard on
git stash
git reset --hard <commit hash>
git pop
# git pull vs git clone
git clone is how you get a local copy of an existing repository to work on. It's usually only used once for a given repository, unless you want to have multiple working copies of it around. ... git pull (or git fetch + git merge ) is how you update that local copy with new commits from the remote repository.