git-tips / tips Goto Github PK
View Code? Open in Web Editor NEWMost commonly used git tips and tricks.
Home Page: http://git.io/git-tips
License: MIT License
Most commonly used git tips and tricks.
Home Page: http://git.io/git-tips
License: MIT License
Please add a short description of how to use doxie to create the README.MD
For ease of memorization and education purposes, some of these tips should have at least short explanations.
Example:
Delete remote branch
git push origin --delete <remote_branchname>
Alternatives:
git push origin :<remote_branchname>
The first command is almost obvious: newcomers to git only have to learn that "origin" is the conventional name of a remote repository, and thus it may be different in some cases. But explaining this may be deferred to git's official docs.
The alternative option is confusing for me even though I've been using git professionally for many years. The explanation is as follows:
Deleting References
You can also use the refspec to delete references from the remote server by running something like this:$ git push origin :topic
Because the refspec is <src>:<dst>, by leaving off the <src> part, this basically says to make the topic branch on the remote nothing, which deletes it.Or you can use the newer syntax (available since Git v1.7.0):
$ git push origin --delete topic
(from https://git-scm.com/book/en/v2/Git-Internals-The-Refspec)
Having short explanations like this, accompanied by links to related parts of official docs, would prevent a lot of cargo-cult-like behavior many git users are falling into.
Arguably, all this deeper knowledge can be found by reading the official docs but having quick access to only related parts would be very convenient for someone like me, who doesn't start with reading a whole book before trying something, but prefers to learn hands-on, step-by-step.
Its showing in another language when i select English... Isn't it available in English?
I have several independent versions, just like ubuntu 14.x, 15.x, 16.x, so that this versions will not be merge.
if I have a commit or hotfix that wants to apply to different versions, how to do with git is the best practice?
such as git cherry-pick git archive git submodule? which can deal with this?
thanks!
fork
It's seems that some git bash commands are working on my machine and it's absolutely updated...
Can someone tell me why?
Sometimes you made a mistake and want to attach couple of commits to another branch
aa -- bb -- cc -- dd -- ee
\ -- ff -- gg
git rebase --onto NEW_BASE OLD_BASE
git rebase --onto gg cc
aa -- bb -- cc
\ -- ff -- gg -- dd -- ee
Failed at the [email protected] postinstall script 'wget https://raw.githubusercontent.com/git-tips/tips/master/tips.json -O tips.json'.
I have a tip which only becomes productive when configured as an alias. Should I submit it?
Hi, I'm mingrammer
I've translated these tips to korean and published on my repository
So, please add this to your README.md
for korean users :D
Here is my github repository : https://github.com/mingrammer/git-tips is for 한국어 (korean language)
Thanks for great tips!!
This is a terrific project, especially for IT Pros like myself trying to learn Git. For those people, I created a simple PowerShell script that I run every time I start PowerShell to display a random tip. You can read about it here: http://bit.ly/1OgpK7O
git branch -dr <remote/branch>
This does not actually delete the branch on the remote as the other two commands this is listed as an alternative for do.
Hello, I wrote a tool that can validate README links (valid URLs, not duplicate). It can be run when someone submits a pull request.
It is currently being used by
Examples
If you are interested, connect this repo to https://travis-ci.org/ and add a .travis.yml
file to the project.
See https://github.com/dkhamsing/awesome_bot for options, more information
Feel free to leave a comment 😄
Hi,
I would like to tranlate your tips in Korean.
But I could not find the way of putting translated files.
If you have any policy, let me know.
Hi there,
The following could be misleading to a novice in GIT:
git fetch origin && git reset --hard origin/master && git clean -f -d
Perhaps this one would suffice:
git fetch origin && git reset --hard HEAD && git clean -f -d
The git-tips project is amazing! It was a great idea to make a usable JSON file. So I thought why not harness the tips.json and make a CLI - https://github.com/nirajpandkar/gtip
Further by tinkering the ~/.bashrc file
one would be greeted with a new git-tip every time he/she opens the terminal. I think this'll help people to easily learn new git tips and tricks!
Feedbacks/Suggestions/Criticism are welcome 😄
Still a WIP. Inspired by @jdhitsolutions's Powershell script
git log --stat
is more verbose than git log
.
git log --stat
gives more info including files added or changed in a commit
It is almost similar to git log
but more verbose.
Can this be included as a tip??
Just a couple sentences above the TOC that would at least include the git version on which these were tested (see also #47). Many operating systems are pinned on older versions with varying behavior. Ideally each command would have an "added in x.x" clause, but I understand if that's going a bit too far.
Hi,
From what I can see, there is no tip talking about rewriting the commit history (authors, messages, dates), which is done with the git-filter-branch
command.
This command is really not easy to use, and I don't see how it would be possible to add a one-line tip about that.
However, I have created a tool to help people doing that. You can check it out at git.io/editor
, and the github repo is here
Do you think it would be possible to add it in the tools section? Or maybe add it in a tip?
Hi,
I think this is a bug ❓
Lines 1089 to 1097 in 8891620
Currently:
Undo local changes with the last content in head
git checkout -- <file_name>
Should be:
Undo local changes with the content in index(staging)
git checkout -- <file_name>
Reference: https://git-scm.com/docs/git-checkout
Examples: git checkout hello.c
restore hello.c from the index
git shortlog
is almost similar to git log
Should I add this or leave it since git shortlog
is much similar in usage git log
??
in Update all the submoudles, it should be submodules
Can this be turned into a command-line utility. Something like this.
import json
from pprint import pprint
from sys import argv
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
if __name__ == '__main__':
SEARCH = ' '.join(argv[1:])
DATA = None
with open('tips.json') as data_file:
DATA = json.load(data_file)
MAX = max(DATA, key=lambda x: similar(SEARCH.lower(), x['title'].lower()))
print(MAX)
Maybe if we get a better string similarity heuristic it would be better something like FuzzyWuzzy. Kindly share your thoughts on it.
Hello,
This git tip is missing from the repo
http://stackoverflow.com/questions/2563632/how-can-i-merge-two-commits-into-one
Hello,
Here is a missing git tip:
http://stackoverflow.com/questions/1783405/checkout-remote-git-branch
By the way, I think it would make sense given the big number of tips to start creating categories, such as "branch", "commit", "pull", "push" ...
Cheers,
Théo
I'm unsure how to install on Cygwin as that uses pact and not npm...any suggestions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.