1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Git workflow help

Discussion in 'HTML, Graphics & Programming' started by hargi, Jun 15, 2018.

  1. hargi

    Wise Guy

    Joined: Jul 19, 2006

    Posts: 1,848

    I'm sure this is quite common but up until recently when I worked on a project it was either on my own or as separate feature requests.

    We currently work as a frontend /backend split which is fine, however, if I have worked on branch x pushed then started working on branch y, then the frontend guy wants a small change on x. I am currently having to commit my work on y then check x out update then move back to y.
    I could do git stash?

    Is there a better way of doing this? It's not the checking out of branches that's really bothering me its the having to open up all the new tabs again for the files I was working on. I'm using VSCode.

    I dont think its possible but what I would like to be able to do is have my editor open on branch y. Then open up a new editor or new instance of that editor and work on branch x but i dont think that is possible

    How do you do this>
     
  2. Poolybit

    Hitman

    Joined: May 14, 2006

    Posts: 943

    Are you working with a local repo or do you have a central server? If the latter, I'd just add the remote to a new directory, check out branch x and open an instance of vscode there to do the work whilst leaving the existing directory alone.
     
  3. hargi

    Wise Guy

    Joined: Jul 19, 2006

    Posts: 1,848

    we use bitbucket server so I could do that
     
  4. JimboTheGiant

    Hitman

    Joined: Feb 12, 2003

    Posts: 880

    Another option is to simply create a new branch whenever you're working on a specific feature or request, rather than working directly on one of the main branches (master, development etc. - however you have it setup).

    That way you can simply do a work-in-progress commit on your feature branch before switching back to work on another branch.

    Jim
     
  5. Dj_Jestar

    Caporegime

    Joined: Oct 18, 2002

    Posts: 28,300

    Location: Back in East London

    1. Finish the bit you're on in branch Y
    2. Commit
    3. Checkout branch X
    4. changes
    5. Commit & push (and merge where necessary)
    6. Checkout branch Y
    7. Resume
     
  6. Dj_Jestar

    Caporegime

    Joined: Oct 18, 2002

    Posts: 28,300

    Location: Back in East London

    It's git.. there is always a local repo.
     
  7. Jamie23

    Gangster

    Joined: Dec 1, 2008

    Posts: 247

  8. jakspyder

    Mobster

    Joined: Aug 12, 2008

    Posts: 2,989

    Location: Edinburgh

    Google git flow. As a basic step its a good start, master branch is production code that when pushed to automatically deployes. Development is the same thing but development code (but remains working code

    Locally, you feature branch. At my work we name the feature branch after the jira task as we're using the atlassian suite.

    When im working on a feature branch, i regularly merge whatever i've branched from (development usually) into my feature branch to ensure i dont get divergence. Then once work is complete, i push the branch. Submit a PR against development that if accepted deletes the branch.

    Naturally this is for a company with more people and a desire to have a log and evidence of stuff, code reviews etc, but it can be adapted nicely for any size project and allows integration of project management tools, CI/CD pipelines, scales to increasing developer counts etc.