- Created: Wednesday, 12 July 2017 15:25
- Written by Ragdata
Create A New GitHub Repository
If you haven't already, you need to make sure that you've installed Git - and in particular Git Bash - for your system.
Head to GitHub, login and create a new repository, then open your favourite console and navigate to your project directory:
If you haven't already created a README file for your new repo, you can do so with the following command:
echo "# raw" >> README.md
Now you can create your new local Git repository, and associate it with the remote GitHub repository you created above:
git init git add README.md git commit -a -m "First Commit" git remote add origin https://github.com/Ragdata/my-project.git git push -u origin master
If you've made changes on both sides of the fence, before making your first push or pull, you're likely to encounter an error.
Try the following before you push again:
git pull --allow-unrelated-histories
Create a Versioned Branch
Let's say that we've been developing
my-project for some time now and it's ready to be released into the wild as version 1.0.
First step is to create the local branch:
git checkout -b 1.0
And then, of course, we're going to want to make that available via GitHub:
git push -u origin 1.0
This handy snippet allows you to store your credentials so that you don't need to provide them with every request.
It is important to note that this is in no way at all secure ...
git config credential.helper store git push http://example.com/repo.git Username: <type your username> Password: <type your password>
[several days later]
git push http://example.com/repo.git
[your credentials are used automatically]
'Forget' Cached Files
Adding an existing file to your
.gitignore file won't remove it from your repository, so you'll need to tell git to 'forget' it:
git rm --cached <file>
If you want to remove a whole folder:
git rm -r --cached <folder>
NOTE: This will not actually remove the files from your local repository - which is handy in the case of IDE config directories and the like - but it will remove the file(s) from other contributor's machines on their next
- << Prev