Monday, July 1, 2013

Using GitHub for Windows with Bitbucket

GitHub is a popular Git version control hosting but it's not provide free unlimited private repositories like Bitbucket. I end up using both. To push files to Bitbucket.org using GitHub for Windows:
  1. Open Git Shell
  2. Change to other directory if need (cd "..\Visual Studio 2012\Projects\DisplayRSSFeeds")
  3. Add .gitignore
  4. Add readme.txt (optional)
  5. Initialize empty git repository: git init
  6. Add the existing files to the repository: git add .
  7. Commit the files: git commit -m "First commit" or git commit -a
  8. Log into Bitbucket.
  9. Create a new repository.
  10. Add a new remote: git remote add origin-bb https://yourusername@bitbucket.org/yourusername/yourgit.git
    (Note: See picture below. You cannot push or remove the remote origin, so just make a new one called origin-bb as I did).
  11. Push up the repo for the first time: git push -u origin-bb --all  




Other git commands
# view current remote
git remote -v

# remove remote
git remote rm origin-bb

# Use these sequence git commands to update Git repository in both local and remote later.
git add .
git commit -a
git push -u

Further reading:
https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project
http://git-scm.com/book/ch2-5.html

No comments: