I have checkout the code few days back (almost a month ago), now i have made same changes but my local copy of code (on my machine) is not updated with the latest code.
now i have to commit my code to team repository in a situation where my local code have some code changes as well as team repository also have some new code.
please help me in simple steps to resolve it.
Thanks !
When you make some changes in your code use the "commit" for updating your local repository, once you're ready to send those changes to the remote server you should "push" and your local commits will be added into the remote server.
Now you have your own version of the code different from the remote servers one so you should "merge" them. I recommend you creating a branch to clear the changes and then merge it with the master.
Using a tool like DiffMerge will make your life easier to merge code.
Related
I have a project running on a remote server. I cloned it into the server to run. Problem is everytime I make a change to the code via git, I have to go into the remote server delete the folder and clone it once again. How can it automatically detect a change in the repo and update it?
You're looking for what's called continuous deployment|delivery.
Since you're using GitHub, you may want to look at GitHub Actions. This is one of many mechanisms that are available.
You can configure Actions to trigger various actions (including building, testing and deployment of your code [to the Digital Ocean droplet]) every time you make a commit.
we have azure devops repo setup with Master > TEST > Development
for last sprint we merged changes from Development to TEST and had merge conflicts
one of the developer created local TEST branch and Merged Development changes to resolve changes and committed changes using local TEST branch
After that pullrequest is created from local TEST branch to Remote TEST branch & completed pull request
Now if we create pullrequest from Development to remote TEST it shows remote TEST is having latest changes
Any help will be appreciated and what all options available to resolve this issue
Flow
Thank you
Dyanesh
Here is my reproduction of your question. Is the process you want to express as shown below?
First clone the remote repo to the local and merge from the local Development branch into the local Test branch. Then push the local Test branch to the remote Test branch.
Then when you create a pull request from the Development branch to the Test branch in azure devops, you get the following prompt.
If so, this is normal, because you have merged the changes from the development branch to the local Test branch locally, and then pushed the changes from the local Test branch to the remote Test branch. At this point, the remote development branch has been synchronized with the Test branch, so naturally there are no changes that need to be merged.
If I misunderstood the issue, please point it out. It would be much easier for people to understand and reply if you could attach screenshots of detailed steps.
Thank you for reply, just after some research i see
1) We merged remote local branch from remote development few times using pullrequest and completing it.
2) After that used same remote local branch to merge changes to remote development branch
3) Now even though remote DEV and TEST branch are in sync, when we do pullrequest from DEV to TEST (remote) it shows still some changes are pending.
how to solve this issue any help will help us resolve this. flow explained in this diagram
Flow
We are using Git for a website project where the develop branch will be the source of the test server, and the master branch will serve as the source for the live, production site. The reason being to keep the git-related steps (switching branches, pushing and pulling) to a minimum for the intended user population. It should be possible for these (not extremely technical) users to run a script that will merge develop into master, after being alerted that this would be pushed to live. master cannot be modified by normal users, only one special user can do the merge.
This is where I'm not sure how to integrate this identity change into my code below:
https://gist.github.com/jfix/9fb7d9e2510d112e83ee49af0fb9e27f
I'm using the simple-git npm library. But more generally, I'm not sure whether what I want to do is actually possible as I can't seem to find information about this anywhere.
My intention would be of course to use a Github personal token instead of a password.
Git itself doesn't do anything about user or permission management. So, the short answer is, don't try to do anything sneaky. Rather, use Github's user accounts they way they were intended.
What I suggest is to give this special user their own Github account, with their own copy of the repo. Let's say the main repo is at https://github.com/yourteam/repo, and the special repo is at https://github.com/special/repo.
The script will pull changes from the team repo's develop branch, and merge this into it's own master branch and push to https://github.com/special/repo.
Then, it will push its changes to the team's master branch. This step can optionally be a forced push, since no one else is supposed to mess with master, anyway. (In case someone does, using a forced push here means they have to fix their local repo to match the team repo later on, rather than having the script fail until someone fixes the team repo.)
At the same time, your CI software will notice that master has changed at https://github.com/special/repo, and will publish as you normally would. This is the linchpin: the CI doesn't pay attention to the team repo, so although your team has permission to change it, those changes don't make it into production.
This special user will need commit access to the team repo, in addition to its own GitHub repo. The easiest way is probably to use an SSH key, and run the git push command from the script, rather than trying to use the GitHub API.
Our entire code base at work is housed on an IIS Windows environment. My task was to
copy the code to our new Linux Ubuntu server and go through the code to make the changes necessary to get it to run on the Linux box. It took a couple months but it works. In the meantime, code updates were made on the productions Windows server to the code base by another developer. Now I have the task of pushing the changes to the Linux box so we can pull the trigger and run it live in the new environment.
PROBLEM:
When I performed a git push origin master I was thrown an error stating that I must perform a pull first. Upon diverging and running a git status it says I have `11 and 3 commits each, respectively. The problem is over the course of 2 months I can't remember all the changes made and something could come crashing down in the Windows environment and that can't happen even for a short time. I just need some advice.
I was wondering if it's possible to create a clone of origin master then push the changes to my local from the prod, merge the files and then upload to the Linux box since I can't push to the Linux now because of the needed pull.
When you do git pull, the changes in the remote origin branch are merged into your local origin branch. That is your "local clone of origin/master," so to speak. Inspect the state of your own master branch, and if everything looks right, then push your changes.
Run gitk --all before and after the pull, and you will see that the merge took place, but only on your system.
Say I have two web servers, one local development and one live.
Under SVN I would checkout the website files to my local webserver's public_html directory and also to the live webserver's public_html directory. I would then work on the files directly on the local server and commit any changes to the central repository.
When I'm ready for those changes to go live on the live server, I would SSH in and perform an SVN update.
Essentially I have two working copies, one on live and one locally, though other users may also have working copies on their local machines. But there will only ever be one working copy on the live server. The reason for this is so that we can just perform SVN update on live server every time we want changes to be published.
How can a simiar workflow be accomplished using GIT?
To model your current work flow almost exactly do:
Set up a git repo.
Clone the repo on the server and locally.
Work locally
git push to the git repo
ssh to server
git pull.
Another way to do it would be to set up a "production" branch in git, have a cron job that continually pulls this branch on the server, and then just merge and push to the "production" branch any time you want to publish your changes. Sounds like you need a more concrete branching strategy.
See: Git flow branching model && git flow cli tool
Good luck! This is a very solvable problem with git.
You might find this useful: http://joemaller.com/990/a-web-focused-git-workflow/
In your local working copy:
git push ssh://you#yourserver/path/to/your/wc
will push the commited changes in your local version to yourserver.
Having a setup that triggers automatically pulling like leonbloy and codemac suggested may seem like a good idea at first but it tends to be very fragile. I suggest a different alternative.
http://toroid.org/ams/git-website-howto