'Is it okay to use git without branches?
I have used git a few times and it has always been a painful experience. However i noticed that bitbucket host private repos for free if less then 5 users and I liked the idea of my source code being secured away from my office.
So I have created a new private repo on bitbucket and because I'm the owner and the only developer and I own the repo I can just make changes locally and then commit and push to my repo (there are no forks) without the added complication of pull requests to the owners repo.
I also realized that I hadn't created a branch and there was no need to, I was just working on my local master branch and committing and pushing to my my master branch, and i could continue this cycle without doing anything else.
So really is there any problem using git like this without using branches.
Solution 1:[1]
First, you will always use a branch (here, by default, master
)
Second, for a simple development workflow like yours, you don't need any additional branches.
But should you want to isolate a development effort in a new branch, that would be as easy as:
git checkout -b newBranch
git add .
git commit -m "New branch"
git push -u origin newBranch # for the first push only
Creating a new branch is just adding a pointer to the current commit: it is a 40 bytes in a file (.git/refs/heads/newBranch
, with the SHA1 of the HEAD commit)
For more on branching:
Solution 2:[2]
It is absolutely fine - just use fork instead of cloning. Branching has the terrible side effect of changing your file system underneath your feet - this is a weakness in the design of git that will no doubt bring great wealth to the person who fixes it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |
Solution 2 | aaaaa |