How to push changes to branch?
3 Steps to Commit your changes
Suppose you have created a new branch on GitHub with the name feature-branch.
FETCH
git pull --all Pull all remote branches
git branch -a List all branches now
Checkout and switch to the feature-branch directory. You can simply copy the branch name from the output of branch -a command above
git checkout -b feature-branch
VALIDATE
Next use the git branch command to see the current branch. It will show feature-branch with * In front of it
git branch check current branch
git status check the state of your codebase
COMMIT
git add . add all untracked files
git commit -m "Rafactore code or use your message"
Take update and the push changes on the origin server
git pull origin feature-branch
git push origin feature-branch
OR you can rebase with the master before commit
git fetch
git rebase origin/master
git push origin feature-branch
First i would like to suggest you to read this nice documentation.
Prerequirements:
- Installed git.
- Have access to the repository.
You can download repository following these commands:
git clone <depositry https or ssh link>
First you need to add changes, create commit, add remote branch and then push.
git remote add <repo name> <repo url>
Example if you use BitBucket: git remote add origin ssh://[email protected]//.gitgit status // to see all changes (they should be printed with red
color)git add <file name> // add the file as git staged
git commit or git commit -m 'some message'
git push <remote name> <branch name>
How to download repository
# download a repository
git clone <url>
How to push changes in selected branch
# push changes to remote branch
# assuming you are on the master branch right now
git push origin master
How to select branch to push
# push any desired branch to remote
git push -u origin local_branch_name:remote_branch_name