10 minute primer:
1. Create the git repository: git init
2. To commit any changes, you type in: git commit -a -m "thing that I changed"
3. To branch, you type in: git checkout -b newbranch
4. To switch back to a branch, you just type in:
git commit -a -m "changes made on branch"
git checkout <branch>
5. To merge in a branch to the current branch, you type in: git merge <branch>
6. To push to a remote repository, you first add a remote repository by typing in the following:
git remote add origin git@example.com:my_project.git
(origin can be anything, but a good convention to use for the main repo that you are pushing to).
Now to push your changes, you just use: git push origin <branch>
Most often you will use: git push origin master
When using Git you sometimes end up with a bunch of changes that would really be better off in a feature branch. Here’s a quick way to take those changes in your working copy and start a feature branch quickly:
git stash
git stash branch my_branch_title
From the docs on git stash branch:
Creates and checks out a new branch named starting from the commit at which the was originally created, applies the changes recorded in to the new working tree and index, then drops the if that completes successfully. When no is given, applies the latest one.
Aliases
http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-examples/
Gerrit is a web based application that allows you to perform code reviews for Git repositories. It’s basically a server that acts as a gatekeeper: developers push their Git changes to it, other developers review them and when these changes are approved,
Gerrit pushes them to the main repository on behalf of the original submitter.
http://blog.evtuhovich.ru/blog/2011/08/23/pro-git/
http://diseaz.github.com/gitmagic/
http://rogerdudler.github.com/git-guide/
http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
http://marklodato.github.com/visual-git-guide/index-en.html
http://sandofsky.com/blog/git-workflow.html
http://try.github.com/levels/1/challenges/1
http://www.appsumo.com/alexteachesgit/
http://www.youtube.com/watch?v=m7r2X9qC8jo
GitHub
Github users can create a new repository called YOUR-GITHUB-NAME.github.com and that’ll be accessible at http://YOUR-GITHUB-NAME.github.com. For example, my repository is sitting at http://github.com/karlseguin/karlseguin.github.com and it’s accessible at http://karlseguin.github.com/. By placing a CNAME file in my root with the contents of openmymind.net and pointing my domain to 207.97.227.245, things just work. Your personal page, like a project page, is a special github project though. Every time you commit, github runs your project through jekyll. Jekyll is a blog-aware site generator which supports templating and a few other nice features
http://klen.github.com/github-blog.html
http://nfarina.com/post/9868516270/git-is-simpler
http://help.github.com/create-a-repo/
http://mlubinsky.github.com/
http://www.blogofile.com/documentation/
http://help.github.com/win-set-up-git/
http://www.paulrohde.com/github-101-on-windows/
http://www.paulrohde.com/up-and-running-with-git-and-visual-studio/
http://blog.iainlobb.com/2009/11/using-git-and-github-on-windows.html
http://code.dblock.org/ShowPost.aspx?id=232 GitHub
http://nathanj.github.com/gitguide/
http://nasko7.blogspot.com/2011/03/simplest-way-to-use-github-on-windows-7.html
Git
http://eagain.net/articles/git-for-computer-scientists/
http://www.g33klaw.com/2012/04/my-problem-with-git-no-abstraction/
http://viget.com/extend/three-magical-git-aliases
http://blog.kfish.org/2010/04/git-lola.html
http://zachholman.com/talk/git-github-secrets
http://www.randyfay.com/node/91
http://news.ycombinator.com/item?id=3891598
http://www.mutuallyhuman.com/blog/2012/06/22/a-git-walkthrough/
http://gitimmersion.com/lab_02.html
http://habrahabr.ru/post/141160/
http://rogerdudler.github.com/git-guide/
http://news.ycombinator.com/item?id=3304847
http://www-cs-students.stanford.edu/~blynn/gitmagic/
http://blog.carbonfive.com/2011/10/10/crafting-commits-in-git/
http://danielmiessler.com/study/git/
http://xeno-by.livejournal.com/64014.html#comments
http://eagain.net/articles/git-for-computer-scientists/
http://kentnguyen.com/development/visualized-git-practices-for-team/
http://www.saintsjd.com/2012/01/a-better-ui-for-git/
http://habrahabr.ru/blogs/Git/137408/
Git GUI
http://www.reddit.com/r/programming/comments/1yqiq8/git_log_is_so_2005/
http://habrahabr.ru/post/206606/ TIG - console gui for Git
http://stackoverflow.com/questions/157476/what-guis-exist-for-git-on-windows
http://code.google.com/p/gitextensions/
http://code.google.com/p/tortoisegit/
http://www.syntevo.com/smartgit/download.html
http://kylecordes.com/2010/git-gui-client-windows
https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools
Simplest workflow usually looks like:
-Do some programming.
-git status to see what files I changed.
-git diff [file] to see exactly what I modified.
-git commit -a -m [message] to commit.
git checkout -b <new-branch> - new branch will be based on current branch
https://programming.d3.ru/podborka-materialov-po-git-1517765/
https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit
https://www.javacodegeeks.com/2016/07/git-tutorial.html
git reset --hard - removes local modifications
git pull origin develop
git merge --no-ff --no-commit filemaker
git diff master -- config/autoload/security.global.php
git diff -w master -- config/autoload/security.global.php
git push --force origin develop
git log mybranchname
After changes committed to your branch, checkout master and pull to get the changes from the repo:
git checkout master
git pull origin master
Then checkout your branch (RB) and rebase your changes on master :
git checkout RB
git rebase master
git push --set-upstream origin develop
http://www.wei-wang.com/ExplainGitWithD3/?__s=abvxhi829nncacieyghm
gitk - visual log viewer https://git-scm.com/docs/gitk
https://www.alexkras.com/getting-started-with-git/
https://github.com/buunguyen/octotree extension to browser
https://www.amazon.com/Rys-Git-Tutorial-Ryan-Hodson-ebook/dp/B00QFIA5OC/ Free e-book
https://www.alexkras.com/how-to-use-git-log-command-line-parameters/ git log
https://www.reddit.com/r/programming/comments/5uj9kc/git_cheat_sheet/
git config -e
git remote -v
git checkout develop
git branch -D master
git checkout master
git pull origin master
git status
Last week, I wrote about objects in Git, and how they're all stored in the .git/objects directory, in files named for the object's SHA-1. To recap: When you commit in Git, you're creating a new object in the Git database. That object points to its parent commit (unless it's the first commit you've made), and to a tree (which is sort of like a directory). That tree, in turn, then points to additional trees (i.e., subdirectories) or to blobs (i.e., files).
When you make a new commit, you're not removing the old commit at all. Indeed, one of the great things about Git is that you have the entire history available to you at all times, letting you compare with previous versions or even retrieve older versions of files. The fact that Git always works locally means that it's also very fast at doing this; it doesn't need to connect to a server on the network in order to compare with or retrieve older versions.
Let's explore this a bit, by creating a new repository, creating some files, and then adding to them:
$ mkdir gitfun $ cd gitfun $ git init Initialized empty Git repository in /Users/reuven/Desktop/gitfun/.git/ $ cat >> test1.txt This is a line in test1. $ git add test1.txt $ git commit -a -m 'Commit #1' [master (root-commit) b9777b2] Commit #1 1 file changed, 1 insertion(+) create mode 100644 test1.txt $ cat >> test1.txt This is a second line in test1. $ cat >> test2.txt This is a first line in test2. $ git add . $ git commit -a -m 'Commit #2' [master ed8047d] Commit #2 2 files changed, 2 insertions(+) create mode 100644 test2.txt $ cat >> test2.txt This is line 2 in test2 $ cat >> test1.txt This is line 3 in test1 $ git add . $ git commit -a -m 'Commit #3' [master 89fdf6d] Commit #3 2 files changed, 2 insertions(+)
I now have three commits, with each commit modifying test1.txt, test2.txt, or both. Here is how the history looks:
commit 89fdf6d0edcd4662e7e9a08f4200badf30b477d5 Author: Reuven Lerner <reuven@lerner.co.il> Date: Sun Jan 15 22:03:39 2017 +0100 Commit #3 commit ed8047d16338b8bc9eb99ebea384614ffee99484 Author: Reuven Lerner <reuven@lerner.co.il> Date: Sun Jan 15 22:03:09 2017 +0100 Commit #2 commit b9777b2cca885c8855ff9f53a034b5914bd97991 Author: Reuven Lerner <reuven@lerner.co.il> Date: Sun Jan 15 22:02:47 2017 +0100 Commit #1
Once again, we can ask the commit to tell us what is in each commit, by using "git cat-file -p". This command, as we saw last time, shows us the contents of a commit object -- or of any other object in Git.
But what if I want to see what things were like way-back-when, back in the first commit (b977)? What if I want to use Git as a sort of filesystem time machine, to turn the clock back and see what things were like back then?
Git actually has a really easy way to do this, but it has a horrible name: "git checkout". I say that "checkout" is a horrible name in no small part because it is the same name as other version-control systems use to retrieve the latest version of something. And "git checkout" most certainly doesn't do that.
The basic definition of "git checkout" is that it moves HEAD. HEAD is the Git way of saying "the current commit." By default, HEAD points to the most recent commit; in the above example, we would expect HEAD to point to my third commit, 89fd. And sure enough, the contents of the .git/HEAD file will reveal what HEAD points to:
$ cat .git/HEAD ref: refs/heads/master
Oh. So actually, HEAD isn't pointing to a commit. Rather, it's pointing to a branch. (What's a branch? We'll get to that soon.) Fortunately, Git uses files for all of this stuff, so I can actually ask for Git to tell me what the "master" branch is pointing to:
$ cat .git/refs/heads/master 89fdf6d0edcd4662e7e9a08f4200badf30b477d5
Sure enough, HEAD points to 89fd, our most recent commit.
The above tells us at least two things:
(1) When we do "ls" or look at the current state of the filesystem, Git will ensure that it reflects the state of the world as stored in 89fd. Any differences between 89fd and our filesystem will be visible with "git status" and "git diff".
(2) When we create a new commit, the parent of our new commit will be 89fd.
Back to the "git checkout" command: Let's say that I want to see what things looked like after committing b977. I can say
git checkout b977
and sure enough, if I look around then I only see "test1.txt" (and don't see "test2.txt"). And the contents of test1.txt reflect the state following my first "git commit".
But if you're trying this at home, then you probably got the following message, too:
Note: checking out 'b977'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at b9777b2... Commit #1
This is Git's way of saying: YOU ARE PLAYING WITH FIRE! WARNING! DON'T DO ANYTHING DUMB HERE!
Why? What has happened? And what could go wrong?
The good news is that when we used "git checkout", we were indeed transported back in time. One of the amazing things about Git is that when you use "git checkout", the filesystem changes to reflect its state when you made that commit. This means that you can explore and look around. Which is great.
However, remember that when you create a new commit, that new commit's parent is the current HEAD. (And then HEAD advances to point to the new commit.) So Git is saying, "Sure, if you create a new commit here, there isn't anything technically wrong. Your new commit's parent will be b977. Which means that b977 will have two different children."
However, Git is also warning us that while making a new commit in this way is technical acceptable, creating a commit without a branch might make it hard for us to find this new commit in the future.
Git tries to save you from yourself not just giving a warning, and by calling this "detached HEAD" state -- normally something I associate with revolutionary France, rather than 21st-century version control software -- but also by telling us how we can create a branch, to get ourselves out of this pickle.
Next week, I'll try to tie this all together, by explaining what branches are (and aren't), and how they relate to the chaos that I've encouraged you to create this week by moving HEAD around.
But before I go, let me point out that if you ever do get yourselves into "detached HEAD" state, you can change that by moving HEAD back... to your current branch, which is called "master" by default. In other words, you can just say:
git checkout HEAD
and then Git will be calmer. And you should be, too.
https://gist.github.com/akras14/3d242d80af8388ebca60 CheetSheet
https://habrahabr.ru/company/softmart/blog/316686/
https://sethrobertson.github.io/GitFixUm/fixup.html
https://codewords.recurse.com/issues/two/git-from-the-inside-out
https://dzone.com/articles/the-2016-git-retrospective-rebase
git checkout master
git pull
git describe --tags
git log
git checkout -b feature/GGA //creates new branch from master
... coding
git add
git commit -m "comment"
git rebase master
git push --force origin feature/GGA
Git clients
https://news.ycombinator.com/item?id=12459755
http://gitboxapp.com/
https://www.atlassian.com/software/sourcetree
https://git-fork.com/
smartgit
http://www.alexkras.com/19-git-tips-for-everyday-use/
https://blog.codeminer42.com/git-workflow-basics-d405746f6205#.u9iuao4i8
https://github.com/optionfactory/digit
https://github.com/jsbin/learn/blob/master/public/help/import-gists.md
https://github.com/jonyeezs/gitreference/wiki
https://www.sitepoint.com/git-branching/
git branch test_branch
git checkout test_branch
2 commands above can be done in single line
git checkout -b test_branch
https://www.algotech.solutions/blog/engineering/git-tips-tricks/
http://sentheon.com/blog/easy-git-guide-and-reference-for-the-busy.html
http://philegelston.com/blog/2016/05/25/git-guts/
http://www.alexkras.com/19-git-tips-for-everyday-use/
https://www.atlassian.com/git/tutorials/advanced-overview/
PULL open source
http://habrahabr.ru/post/275219/ how to contribute to open source project
https://yangsu.github.io/pull-request-tutorial/
http://www.bemmu.com/how-to-create-a-pull-request-on-github
http://zeroturnaround.com/rebellabs/git-commands-and-best-practices-cheat-sheet/
https://medium.com/@pierreda/git-rebase-and-the-golden-rule-explained-70715eccc372#.ty4djxapv REBASE
http://users.livejournal.com/_winnie/407870.html SVN
https://news.ycombinator.com/item?id=10121997
https://www.atlassian.com/git/tutorials/comparing-workflows/centralized-workflow
http://www.bitsnbites.eu/?p=221 clean history
http://www.gitguys.com/topics/creating-and-playing-with-branches/
http://habrahabr.ru/post/268951/
gitgutter: http://jonathanmh.com/best-git-tools-gitgutter-show-changed-lines-in-your-editor/#more-1221
http://habrahabr.ru/company/mailru/blog/267595/
https://github.com/maryrosecook/essays/blob/master/gitfromtheinsideout/essay.md
http://conceptf1.blogspot.it/2014/07/git-branches-and-conflict-merge.html
http://ru-webdev.livejournal.com/3288440.html
https://news.ycombinator.com/item?id=9520145 git explained
http://tom.preston-werner.com/2009/05/19/the-git-parable.html
http://wildlyinaccurate.com/a-hackers-guide-to-git/
https://codewords.recurse.com/issues/two/git-from-the-inside-out
https://jwiegley.github.io/git-from-the-bottom-up/
https://www.atlassian.com/git/
http://www.andrewconnell.com/blog/squash-multiple-git-commits-into-one
http://gitlet.maryrosecook.com/docs/gitlet.html
https://pcottle.github.io/learnGitBranching/
http://41j.com/blog/2015/02/common-git-screwupsquestions-solutions/
http://www.reddit.com/r/programming/comments/2y09h8/most_common_git_screwups_and_their_solutions/
https://www.andyjeffries.co.uk/25-tips-for-intermediate-git-users/
http://mrchlblng.me/2014/09/practical-git-introduction/
http://thelinell.com/2014/12/23/curated-git-links-of-2014/
http://www.gotealeaf.com/books/git
http://justinhileman.info/article/git-pretty/
https://wildlyinaccurate.com/a-hackers-guide-to-git
http://www.garyrobinson.net/2014/10/git-in-two-minutes-for-a-solo-developer.html
http://gitlet.maryrosecook.com/
Git-Flow
https://veerasundar.com/blog/2018/03/gitflow-animated/
http://nvie.com/img/git-model@2x.png
http://vallandingham.me/git-workflow.html
http://revgov.co.uk/blog/tutorial-what-is-git-flow
https://habrahabr.ru/post/106912/
https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
https://www.atlassian.com/git/tutorials/comparing-workflows/
https://news.ycombinator.com/item?id=11777472
origin/master - the main branch where the source code of HEAD always reflects a production-ready state.
origin/develop - latest delivered development changes for the next release. Some would call this the “integration branch”. This is where any automatic nightly builds are built from.
When the source code in the develop branch reaches a stable point and is ready to be released, all of the changes should be merged back into master and then tagged with a release number
http://blog.funda.nl/creating-a-custom-git-flow-visualization/
http://www.codesherpas.com/screencasts/on_the_path_gitflow.mov
https://news.ycombinator.com/item?id=9744059
http://nvie.com/posts/a-successful-git-branching-model/
Hotfix branches are created from master; new features branches are created from develop
git checkout -b my_branch_name master (or develop)
git checkout master
git merge --no-ff <your hotfix_branch here>
git tag
git tag -a v2.0.2
git push --tags
https://pypi.python.org/pypi/nu-gitflow/
blog post http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow.
gitflow screen casts:
How to use a scalable Git branching model called git-flow (by Build a Module)
A short introduction to git-flow (by Mark Derricutt)
On the path with git-flow (by Dave Bock)
GIT HOOKS
http://robots.thoughtbot.com/use-git-hooks-to-automate-annoying-tasks
http://opcode.org/peepcode-git.pdf
http://wildlyinaccurate.com/a-hackers-guide-to-git
http://pcottle.github.io/learnGitBranching/?NODEMO
http://rogerdudler.github.io/git-guide/
http://www.git-tower.com/learn/
http://www.wei-wang.com/ExplainGitWithD3/
https://news.ycombinator.com/item?id=7450528
Python
http://www.leaseweblabs.com/2013/12/learn-python-automate-your-routine-with-a-python-script/
http://www.stavros.io/posts/more-pep8-git-hooks/ Git pre-commit hook to run flake
http://victorlin.me/posts/2014/02/05/auto-post-commit-pep8-correction
http://www.stavros.io/posts/pep8-git-hooks/
gitignore: get rid of .pyc and other files
http://codeinthehole.com/writing/a-useful-git-post-checkout-hook-for-python-repos/
sudo find . -type f -name *.pyc -exec chmod 666 {} \;
/.gitconfig
git config -l
http://stackoverflow.com/questions/10376913/git-ignoring-gitconfig
https://github.com/github/gitignore
create a file named .gitignore with the following contents:
*.pyc__pycache__
http://smangelsdorf.github.io/blog/2014/02/17/git-is-a-directed-acyclic-graph/
http://chriskottom.com/blog/2014/02/a-few-modest-best-practices-for-git/
https://news.ycombinator.com/item?id=7166058
https://ochronus.com/git-tips-from-the-trenches/
http://devcharm.com/pages/46-improve-your-git-workflow
http://sethrobertson.github.io/GitBestPractices/
http://www.ndpsoftware.com/git-cheatsheet.html
https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#git
http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/
Implementing Git in JS:
http://kushagragour.in/blog/2014/01/build-git-learn-git/
Windows github client
GitHub
https://habrahabr.ru/company/2gis/blog/306166/
https://github.com/mlubinsky/mlubinsky.github.com vantive98
The authenticity of host 'github.com (192.30.252.130)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
https://help.github.com/articles/generating-ssh-keys/
Github Pages
https://help.github.com/categories/github-pages-basics/
https://github.com/maxogden/gh-pages-template#readme
http://openmymind.net/2011/10/11/This-Blog-Is-Now-Hosted-On-Github/
http://www.reddit.com/r/javascript/comments/1z86gm/til_you_can_host_webpages_through_your_github/
https://news.ycombinator.com/item?id=12100496
https://github.com/blog/1081-instantly-beautiful-project-pages
Git workflow
http://blogs.atlassian.com/2014/01/simple-git-workflow-simple/
https://news.ycombinator.com/item?id=7036628
http://www.reddit.com/r/programming/comments/1uvrin/simple_git_workflow_is_simple/
http://vimeo.com/49444883 Advanced Git
http://zachholman.com/talk/more-git-and-github-secrets/
http://glennstovall.com/blog/2013/03/15/how-i-use-git/
https://sandofsky.com/blog/git-workflow.html
http://techblog.rosedu.org/git-is-the-answer-1.html
http://pcottle.github.io/learnGitBranching/
http://habrahabr.ru/post/195674/ merge
http://habrahabr.ru/company/badoo/blog/193258/
http://www.youtube.com/watch?v=ZDR433b0HJY
http://www.jayway.com/2013/03/03/git-is-a-purely-functional-data-structure/
http://www.reddit.com/r/programming/comments/1p1fz0/over_40_scenarios_to_help_your_improve_your_git/
Git commit message format
A short summary of the change (MUST be < 62 chars)
A detailed summary of the committed changes. May have bullet points
or paragraphs. SHOULD break between 80-100 chars, but is not enforced.
Bug: 1234
Git
http://gitolite.com/gcs/index.html
GUI for Git
https://github.com/FredrikNoren/ungit
http://www.syntevo.com/smartgithg/index.html
http://blog.bitbucket.org/2013/03/19/introducing-sourcetree-git-client-microsoft-windows/
1) Repository:
it is a collection of commits; commit is archive of project working tree
it has HEAD, which identifies contains the set of branches and tags
2) Index(staging area):
Git does not commit changes directly from the working tree into the repository. Instead,
changes are first registered in something called the index (staging area)
3) A working Area (Tree):
is any directory on your filesystem which has a repository (has subdir .git)
Editing is happening in Working Area
"git add" really means "git stage"
Branches are merely pointers to commits
REBASE
http://habrahabr.ru/post/161009/
http://infinitemonkeys.influitive.com/a-simple-explanation-for-git-rebase/
You can do a "git fetch" at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working area.
git pull : retrieve
git add : copy from Working to Staging area
git commit : copy from staging area to repo (local branch)
git push <remote> : to upstream server (remote branch)
http://stackoverflow.com/questions/15316601/why-is-git-pull-considered-harmful
HEAD points to the commit that is currently checked out
git diff : between Working and Staging
git diff --staged : between Staging and Repo
git diff HEAD : between Working and Repo
git diff only shows changes in your working tree that you have not staged or committed yet.
You can view the difference between what you have staged and what is in the repository
by adding --cached to the git diff
http://git-scm.com/docs/git-difftool.html
merge versus rebase
http://lwn.net/Articles/328436/
http://lwn.net/Articles/328438/
Merge conflict resolution
git config --global merge.tool vimdiff
git mergetool
http://gitfu.wordpress.com/2008/06/09/git-mergetool-when-just-doesnt-cut-it/
http://usevim.com/2012/03/21/git-and-vimdiff/
http://habrahabr.ru/post/209400/
http://cuppster.com/2011/02/08/how-to-setup-gits-difftool-on-windows/#disqus_thread
http://blog.ezyang.com/2010/01/advanced-git-merge/
In case you got conflicts during an operation like merge, rebase, cherry-pick, ... Git will add conflict markers to the files with conflicts. This looks e.g. like this
<<<<<<< HEAD print 123 ======= print 234 >>>>>>> origin/dev
You will find the local (original) version before the break and the conflicting version introduced during the operation right after the break.
To solve the conflict you can either fix the file by hand or (the recommended way) use
$ git mergetool
Undoing in Git
http://sethrobertson.github.io/GitFixUm/fixup.html
https://github.com/blog/2019-how-to-undo-almost-anything-with-git
https://news.ycombinator.com/item?id=6909146
http://robots.thoughtbot.com/use-git-hooks-to-automate-annoying-tasks
http://git-scm.com/book/en/Git-Basics-Undoing-Things
http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit
http://giallone.blogspot.gr/2012/12/git-lets-make-errors-and-learn-how-to.html
To undo "git add files" do this: git reset -- files
To unstage everything: git reset
To throw away the changes in Working area: git checkout --files (it copies files from stage to working area)
If you want to revert changes made to your working copy:
git checkout .
If you want to revert changes made to the index (i.e., that you have added):
git reset
If you want to revert a change that you have committed:
git revert ...
Assuming you have done a git fetch recently,
the following will discard everything in your local and
reset it to the point you specify as the final argument
(in this case the current HEAD of the origin/master remote tracking branch):
$ git reset --hard origin/master
Your branch is ahead of 'origin/master' by 1 commit
git log
git log origin/Wipe
git reset --soft HEAD^ (save your changes, back to last commit))
git reset --hard HEAD^ (discard changes, back to last commit)
git reset --hard origin/Wipe
origin/master is a remote tracking branch that records the status of the remote repository from your last push, pull, or fetch.
Your branch and 'origin/master' have diverged, # and have 1 and 12 different commit(s)
# Your branch and 'origin/Wipe' have diverged,
# and have 1 and 2 different commits each, respectively.
http://stackoverflow.com/questions/53569/how-to-get-the-changes-on-a-branch-in-git
http://stackoverflow.com/questions/8716130/git-branches-diverged-how-to-proceed
git log HEAD..origin/Wipe
http://sebgoo.blogspot.com/2012/02/git-your-branch-and-originxxx-have.html
You need to push to the remote master. Run "git diff origin/master" to see what the differences are between your local repository and the remote master repository
git pull --rebase <- after that I got "Your branch is ahead of 'origin/Wipe' by 1 commit"
Answer
It’s telling you exactly what you did; you got ahead of the remote and it’s reminding you to push.
Video:
http://pcottle.github.com/learnGitBranching/
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
Git push permissions error
cd .git/objects ls -al sudo chown -R yourname:yourgroup *
git mv A B : same as: mv A B ; git add -A .
git branch : local branches
git branch -r : remote branches
git branch -a : all branches
Default remote is origin
default branch name is master
git branch namehere : creates new branch
git checkout -b <local_branch_name> origin/master
GIT prompt
https://github.com/magicmonty/bash-git-prompt
http://stackoverflow.com/questions/15883416/adding-git-branch-on-the-bash-command-prompt
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh PS1="[\[\033[32m\]\w]\[\033[0m\]\$(__git_ps1)\n\[\033[1;36m\]\u\[\033[32m\]$ \[\ \033[0m\]
http://code-worrier.com/blog/git-branch-in-bash-prompt/
http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
Switching between local branches
#!/bin/bash
branches=()
eval "$(git for-each-ref --shell --format='branches+=(%(refname:short))' refs/heads/)"
# Set the prompt for the select command
PS3="Select a branch. 'q' to quit: "
select branch in "${branches[@]}"
do
if [ -n "$branch" ]; then
git checkout $branch
fi
break
done
http://habrahabr.ru/post/157175/
amend
http://blog.jacius.info/2008/6/22/git-tip-fix-a-mistake-in-a-previous-commit/
http://git-scm.com/book/en/Git-Basics-Undoing-Things
http://git-scm.com/book/ch6-4.html
http://www-cs-students.stanford.edu/~blynn/gitmagic/ch02.html
http://durdn.com/blog/2012/12/05/git-12-curated-git-tips-and-workflows/
http://media.pragprog.com/titles/tsgit/chap-005-extract.html
http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
http://sitaramc.github.com/gcs/
http://www.gitguys.com/topics/
http://git-scm.com/book/en/Git-Tools-Debugging-with-Git
http://www.sbf5.com/~cduan/technical/git/
http://andyjeffries.co.uk/articles/25-tips-for-intermediate-git-users
http://techblog.rosedu.org/git-good-practices.html
http://habrahabr.ru/post/155391/
http://techblog.rosedu.org/git-useful-aliases.html
http://techblog.rosedu.org/git-speeding-workflow.html
http://rakeroutes.com/blog/getting-up-to-speed-on-a-new-git-repo/
http://osteele.com/archives/2008/05/commit-policies
https://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/
http://news.ycombinator.com/item?id=4340047
http://tom.preston-werner.com/2009/05/19/the-git-parable.html
http://nvie.com/posts/a-successful-git-branching-model/
Branching in git is simple and makes local development easier.
master: git checkout -b some_branch some_branch: vim some_file.rb some_branch: git add some_file.rb some_branch: git commit -m "commiting some_file.rb" some_branch: git checkout master /* wait a few days because your company's project managers can't make up their minds */ master: git pull origin master master: git checkout some_branch some_branch: git rebase master some_branch: git checkout master master: git merge some_branch master: git push origin master master: git branch -d some_branch
git add [file] : tell Git to track a new file.
git commit -a -m "Commit message" : commit the changes you have made to your local repository.
git push : push your changes to the “server”.
git clone or git pull to download a repository to your machine.
git checkout : to checkout files from a particular branch into the current working directory Checkout means "check branch x out"
Stashes - an extremely useful feature. If you are in the middle of working on something and you want to switch branches, you normally don't want to commit those changes. So what you do is "stash" the changes onto a stack. You can reapply them later. Some excellent info can be found here: http://git-scm.com/book/en/Git-Tools-Stashing
git stash git show git pop git apply
Merge conflict resolution
git config --global merge.tool vimdiff
git mergetool
http://gitfu.wordpress.com/2008/06/09/git-mergetool-when-just-doesnt-cut-it/
The homebrew version of the Git is bundled with two Git GUI frontends called gitk (invoked with `gitk`) and git-ui (invoked with `git gui`)