Send specific branch with Git to Github

Asked

Viewed 1,652 times

2

how I can send a specific branch to Github through Git?

I am creating a project to learn how to use Gulp and its plugins, and in it I created a folder with source code, called src and a folder containing the minified files, processed CSS sheets and so on, called build. I tried to create a branch in Git called deploy and just add the build files to that branch and then do the pull to the repository, but I can’t just send this folder.

In the various tests I did sometimes goes the whole project, with the folder src, sometimes another remote branch is created in the repository..

Do you have any organizing tips of this type, for projects with task Runners?

2 answers

2


Git is not meant to be used as you think. If you store the build generated by your code it makes more sense to have another repository just for the build. Or keep a subfolder called build that is always versioned along with the code that generated that build.

In my opinion, building doesn’t make much sense. Because you can always generate the build from a given git commit. I would put my build only as a file to be published on the server in the middle of the deploy pipeline.

  • How does this deploy pipeline work? Does Gulp itself have a deploy function, or a plugin designed for this? Maybe that’s exactly the answer. The reason I included the build in the versioning was just not knowing how to deploy later (without FTP or similar).

  • It depends on how you want to deploy, but Gulp has many libraries to help deploy. For example if you want to send only the static files to the AWS vc has a Gulp plugin that communicates with S3 and stores everything there. If you have virtual machines that run in the cloud, you can send a zipped file with your build to some cloud server and have your virtual machine download that file. Another option would be to use Gulp to send directly to your VM via ftp. There are numerous options at this point of the deploy.

  • I’ll look into it. Thanks for the directions!

1

When you already have your repository empty on github, you can take the reference in two ways.

  • Cloning the repository

Thus, you use the url to clone (download) the repository to your computer using git clone.

$ git clone http://github.com/<user>/<repository>.git <nome da pasta>

  • Starting a git project(I believe that’s your case)

You should start your project folder and refer to your repository on github.

$ cd <pasta do projeto>
$ git init
$ git add <pasta que deseja adicionar ao repositório>
$ git commit -m "comentário"
$ git remote add origin http://github.com/<user>/<repository>.git
$ git push origin master

If you do not accept git push origin master, may be in case there are already files in your repository. Then pull should be done before sending new files.

$ git pull origin master
$ git push origin master

With the second method, you can choose which files and folders you want to upload to your repository on github.

  • But that way my master branch will be pushed, right? That way goes the folder too src. For example, can you just send another created branch and the files that were added to it? An orphaned branch deploy for example, only with build files?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.