Tag: git

  • Reference: Import existing source code to GitHub

    If you’ve got local source code you want to add to a new remote new git repository without ‘cloning’ the remote first, do the following (I often do this – you create your remote empty repository in bitbucket/github, then push up your source)

    1. Create the remote repository, and get the URL such as git@github.com:/youruser/somename.git or https://github.com/youruser/somename.gitIf your local GIT repo is already set up, skips steps 2 and 3
    2. Locally, at the root directory of your source, git init2a. If you initialize the repo with a .gitignore and a README.md you should do a git pull {url from step 1} to ensure you don’t commit files to source that you want to ignore ;)
    3. Locally, add and commit what you want in your initial repo (for everything, git add . then git commit -m 'initial commit comment')
    4. to attach your remote repo with the name ‘origin’ (like cloning would do)
      git remote add origin [URL From Step 1]
    5. Execute git pull origin master to pull the remote branch so that they are in sync.
    6. to push up your master branch (change master to something else for a different branch):
      git push origin master

    https://stackoverflow.com/a/8012698/61902

  • Linking GitHub issues to commits

    Connect an issue with a commit after the commit

    In your issue on GitHub, just write a comment with the commit hash. For instance:

    Fixed with commit 61d949320fc0bf1a8dba09b3845bddcd153b1a64

    https://stackoverflow.com/questions/19036161/connect-an-issue-with-a-commit-after-the-commit#26835572


    Link to the issue number on GitHub within a commit message

    …you can use these synonyms to reference an issue and close it (in your commit message): ..

    fixes #xxx

    https://stackoverflow.com/questions/1687262/link-to-the-issue-number-on-github-within-a-commit-message?rq=1

  • git – duplicate a repo without forking

    mkdir foo; cd foo 
    # move to a scratch dir
    
    git clone --bare https://github.com/exampleuser/old-repository.git
    # Make a bare clone of the repository
    
    cd old-repository.git
    git push --mirror https://github.com/exampleuser/new-repository.git
    # Mirror-push to the new repository
    
    cd ..
    rm -rf old-repository.git  
    # Remove our temporary local repository
    
    https://stackoverflow.com/questions/6613166/how-to-duplicate-a-git-repository-without-forking
  • git source control with a local repository (no server)

    Even when working alone or on simple projects, I like to have the benefits of source control – history, branching, and backup.

    (more…)