-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGITHELP
85 lines (67 loc) · 2.68 KB
/
GITHELP
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
Quick git user's guide
# NOTES: You should run 'git pull' or 'git pull --all' often
# to make sure you pull down changes others have pushed. If you don't,
# you may find yourself trying to push changes that won't merge.
# Committing does not transfer any data, it just marks groups of
# changes on your local machine. Pushing is how you get changes to
# the central repository, and you can push one or more commits at once.
# HOW TO CODE A NEW FEATURE: Create a new branch. Code your changes against the
# new branch. If you decide that your new feature is good enough
# to be included in the master branch, checkout the master branch and
# merge your changes.
git checkout -b newbranch master
# code
git add changedfiles
git commit
git checkout master
git pull origin master
git merge newbranch # this will commit automatically
git push origin master
# You will also have to merge newbranch into any other branches you want
# the new feature in.
git checkout someotherbranch
git merge newbranch
git push origin someotherbranch
# Download the repository for the first time:
git checkout [email protected]:erinspice/geni-automerge.git
# Save a remote (kind of like a link) to the repository for easy pulling and pushing.
git remote add origin [email protected]:erinspice/geni-automerge.git
# Tell git what who you are if you haven't set git up yet:
git config --global user.name "First Last"
git config --global user.email [email protected]
# List all branches.
git branch -a
# get all the latest changes from the server:
# be sure to do this EVERY TIME you switch to a branch that
# already exists in the repository!!!!
git pull origin branchname
# create a new branch
git checkout -b mynewbranch master
# switch branches
git checkout somebranch
# list changes
git status
# diff
git diff # if you have not committed yet
git diff --cached # if you have committed already
# commit changes
# note that you have to re-add changed files after a commit
git add changed-file-one.txt changed-file-two.txt
git commit -m "This is my commit message!"
# push changes to one branch the server
git push origin branchtopush
# push changes to all branches that already exist on the server
git push
# push changes to all branches that already exist
# and push newly created branches
git push --all
# findout what pushing would do
git push --dry-run [options as listed above]
# undo a commit to add more changes or change a commit message
# the ^ means reset to the next-to-last commit, --soft means to not actually
# change any files on the disk. This basically resets your history
# without blowing away your code.
git reset --soft HEAD^
# undo all uncommitted changes
# no ^ means reset to the last commit
git reset --hard HEAD