Wednesday, November 2, 2016

git new branch and push from command line

Go to (cd) to git repo.
1. Make a new branch :
git checkout -b newBranchName

git checkout -b a10

2. Make changes are add all edited files to that branch in current and sub folders:

  git add .

3. Commit to local branch, example:

git commit -m "changes for release a10 issue 3291 user addresses" 

4. Till now everything is on local, to push generally will do:

git push 

5. But since this is a new local branch need to tell git which remote branch it should point to, it does not assume it will have the same remote name, helps us by giving error message:
fatal: The current branch test has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin test


So now give command:

    git push --set-upstream origin test

if your remote auth is set up should push the changes. If branch is there on remote, made by someone else will get errors.

Generally need to do steps 2,3 and 4. Or can use your IDE to do the same.

A good stand alone UI is https://www.gitkraken.com/features need this for multiple branches for simple one branch work IDE with git plugin is enough or the command line.


No comments:

Post a Comment

Followers